Skip to content

Commit

Permalink
Merge branch 'master' of github.com:JuliaLang/julia
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 25, 2014
2 parents 31147e6 + 13fbba4 commit be1aa2d
Show file tree
Hide file tree
Showing 21 changed files with 355 additions and 127 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ Deprecated or removed

* `readsfrom` and `writesto` are replaced by `open` ([#6948]).

* `insert!` now throws a `BoundsError` if
`index > length(collection)+1` ([#7373]).

[#4042]: https://github.com/JuliaLang/julia/issues/4042
[#5164]: https://github.com/JuliaLang/julia/issues/5164
[#4026]: https://github.com/JuliaLang/julia/issues/4026
Expand Down Expand Up @@ -452,6 +455,7 @@ Deprecated or removed
[#6624]: https://github.com/JuliaLang/julia/pull/6624
[#5936]: https://github.com/JuliaLang/julia/issues/5936
[#6179]: https://github.com/JuliaLang/julia/issues/6179
[#7373]: https://github.com/JuliaLang/julia/issues/7373

Julia v0.2.0 Release Notes
==========================
Expand Down
13 changes: 4 additions & 9 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,16 +537,11 @@ function shift!(a::Vector)
end

function insert!{T}(a::Array{T,1}, i::Integer, item)
if i < 1
throw(BoundsError())
end
1 <= i <= length(a)+1 || throw(BoundsError())
i == length(a)+1 && return push!(a, item)

item = convert(T, item)
n = length(a)
if i > n
ccall(:jl_array_grow_end, Void, (Any, Uint), a, i-n)
else
_growat!(a, i, 1)
end
_growat!(a, i, 1)
a[i] = item
return a
end
Expand Down
38 changes: 17 additions & 21 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -592,34 +592,30 @@ function shift!(B::BitVector)
end

function insert!(B::BitVector, i::Integer, item)
i < 1 && throw(BoundsError())
item = convert(Bool, item)

n = length(B)
if i > n
x = falses(i - n)
append!(B, x)
else
Bc = B.chunks
1 <= i <= n+1 || throw(BoundsError())
item = convert(Bool, item)

k, j = get_chunks_id(i)
Bc = B.chunks

l = @_mod64 length(B)
if l == 0
ccall(:jl_array_grow_end, Void, (Any, Uint), Bc, 1)
Bc[end] = uint64(0)
end
B.len += 1
k, j = get_chunks_id(i)

for t = length(Bc) : -1 : k + 1
Bc[t] = (Bc[t] << 1) | (Bc[t - 1] >>> 63)
end
l = @_mod64 length(B)
if l == 0
ccall(:jl_array_grow_end, Void, (Any, Uint), Bc, 1)
Bc[end] = uint64(0)
end
B.len += 1

msk_aft = (_msk64 << j)
msk_bef = ~msk_aft
Bc[k] = (msk_bef & Bc[k]) | ((msk_aft & Bc[k]) << 1)
for t = length(Bc) : -1 : k + 1
Bc[t] = (Bc[t] << 1) | (Bc[t - 1] >>> 63)
end

msk_aft = (_msk64 << j)
msk_bef = ~msk_aft
Bc[k] = (msk_bef & Bc[k]) | ((msk_aft & Bc[k]) << 1)
B[i] = item
B
end

function _deleteat!(B::BitVector, i::Integer)
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ function tty_cols()
tty_size()[2]
end

@deprecate pointer{T}(::Type{T}, x::Uint) convert(Ptr{T}, x)
@deprecate pointer{T}(::Type{T}, x::Ptr) convert(Ptr{T}, x)

# 0.3 discontinued functions

scale!{T<:Base.LinAlg.BlasReal}(X::Array{T}, s::Complex) = error("scale!: Cannot scale a real array by a complex value in-place. Use scale(X::Array{Real}, s::Complex) instead.")
Expand Down
8 changes: 4 additions & 4 deletions base/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ end

empty!(t::ObjectIdDict) = (t.ht = cell(length(t.ht)); t)

start(t::ObjectIdDict) = 0
done(t::ObjectIdDict, i) = is(next(t,i),())
next(t::ObjectIdDict, i) = ccall(:jl_eqtable_next, Any, (Any, Uint32), t.ht, i)
_oidd_nextind(a, i) = int(ccall(:jl_eqtable_nextind, Csize_t, (Any, Csize_t), a, i))

isempty(t::ObjectIdDict) = is(next(t,0),())
start(t::ObjectIdDict) = _oidd_nextind(t.ht, 0)
done(t::ObjectIdDict, i) = (i == -1)
next(t::ObjectIdDict, i) = ((t.ht[i+1],t.ht[i+2]), _oidd_nextind(t.ht, i+2))

function length(d::ObjectIdDict)
n = 0
Expand Down
7 changes: 7 additions & 0 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,13 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast)
return (e.args[3],())
end
end
if is(f, typeassert) && length(atypes)==2
# typeassert(x::S, T) => x, when S<:T
if isType(atypes[2]) && isleaftype(atypes[2]) &&
atypes[1] <: atypes[2].parameters[1]
return (e.args[2],())
end
end
if length(atypes)==2 && is(f,unbox) && isa(atypes[2],DataType) && !atypes[2].mutable && atypes[2].pointerfree
# remove redundant unbox
return (e.args[3],())
Expand Down
4 changes: 2 additions & 2 deletions base/mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::IO, offset::File
else
pmap, delta = mmap(len, prot, flags, fd(s), offset)
end
A = pointer_to_array(pointer(T, uint(pmap)+delta), dims)
A = pointer_to_array(convert(Ptr{T}, uint(pmap)+delta), dims)
finalizer(A,x->munmap(pmap,len+delta))
return A
end
Expand Down Expand Up @@ -149,7 +149,7 @@ function mmap_array{T,N}(::Type{T}, dims::NTuple{N,Integer}, s::IO, offset::File
if viewhandle == C_NULL
error("could not create mapping view: $(FormatMessage())")
end
A = pointer_to_array(pointer(T, viewhandle+offset-offset_page), dims)
A = pointer_to_array(convert(Ptr{T}, viewhandle+offset-offset_page), dims)
finalizer(A, x->munmap(viewhandle, mmaphandle))
return A
end
Expand Down
4 changes: 2 additions & 2 deletions base/multimedia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ end

function redisplay(x)
for i = length(displays):-1:1
applicable(redisplay, displays[i], x) &&
xdisplayable(displays[i], x) &&
@try_display return redisplay(displays[i], x)
end
throw(MethodError(redisplay, (x,)))
end

function redisplay(m::Union(MIME,String), x)
for i = length(displays):-1:1
applicable(redisplay, displays[i], m, x) &&
xdisplayable(displays[i], m, x) &&
@try_display return redisplay(displays[i], m, x)
end
throw(MethodError(redisplay, (m, x)))
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function clone(url::String, pkg::String)
Git.run(`clone -q $url $pkg`)
Git.set_remote_url(url, dir=pkg)
catch
rm(pkg, recursive=true)
Base.rm(pkg, recursive=true)
rethrow()
end
isempty(Reqs.parse("$pkg/REQUIRE")) && return
Expand Down
2 changes: 0 additions & 2 deletions base/pointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ convert(::Type{Ptr{Int8}}, s::ByteString) = convert(Ptr{Int8}, s.data)
convert{T}(::Type{Ptr{T}}, a::Array{T}) = ccall(:jl_array_ptr, Ptr{T}, (Any,), a)
convert(::Type{Ptr{None}}, a::Array) = ccall(:jl_array_ptr, Ptr{None}, (Any,), a)

pointer{T}(::Type{T}, x::Uint) = convert(Ptr{T}, x)
pointer{T}(::Type{T}, x::Ptr) = convert(Ptr{T}, x)
# note: these definitions don't mean any AbstractArray is convertible to
# pointer. they just map the array element type to the pointer type for
# convenience in cases that work.
Expand Down
2 changes: 1 addition & 1 deletion base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,4 @@ function in(x, r::Range)
n >= 1 && n <= length(r) && r[n] == x
end

in{T<:Integer}(x, r::Range{T}) = isinteger(x) && !isempty(r) && x>=minimum(r) && x<=maximum(r) && (step(r)==0 || mod(int(x)-first(r),step(r))==0)
in{T<:Integer}(x, r::Range{T}) = isinteger(x) && !isempty(r) && x>=minimum(r) && x<=maximum(r) && (mod(int(x)-first(r),step(r))==0)
13 changes: 7 additions & 6 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ mapreduce_impl(f, op, A::AbstractArray, ifirst::Int, ilast::Int) =

# handling empty arrays
mr_empty(f, op, T) = error("Reducing over an empty array is not allowed.")
mr_empty(::IdFun, op::AddFun, T) = r_promote(op, zero(T))
mr_empty(::AbsFun, op::AddFun, T) = r_promote(op, abs(zero(T)))
mr_empty(::Abs2Fun, op::AddFun, T) = r_promote(op, abs2(zero(T)))
mr_empty(::IdFun, op::MulFun, T) = r_promote(op, one(T))
mr_empty(::AbsFun, op::MaxFun, T) = abs(zero(T))
mr_empty(::Abs2Fun, op::MaxFun, T) = abs2(zero(T))
# use zero(T)::T to improve type information when zero(T) is not defined
mr_empty(::IdFun, op::AddFun, T) = r_promote(op, zero(T)::T)
mr_empty(::AbsFun, op::AddFun, T) = r_promote(op, abs(zero(T)::T))
mr_empty(::Abs2Fun, op::AddFun, T) = r_promote(op, abs2(zero(T)::T))
mr_empty(::IdFun, op::MulFun, T) = r_promote(op, one(T)::T)
mr_empty(::AbsFun, op::MaxFun, T) = abs(zero(T)::T)
mr_empty(::Abs2Fun, op::MaxFun, T) = abs2(zero(T)::T)
mr_empty(f, op::AndFun, T) = true
mr_empty(f, op::OrFun, T) = false

Expand Down
2 changes: 1 addition & 1 deletion base/serialize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function deserialize(s, ::Type{DataType})
deserialize(s, t)
end

deserialize{T}(s, ::Type{Ptr{T}}) = pointer(T, 0)
deserialize{T}(s, ::Type{Ptr{T}}) = convert(Ptr{T}, 0)

function deserialize(s, ::Type{Task})
t = Task(deserialize(s))
Expand Down
32 changes: 32 additions & 0 deletions base/utf8proc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,38 @@ export normalize_string, is_valid_char, is_assigned_char
# whether codepoints are valid Unicode
is_valid_char(c) = bool(ccall(:utf8proc_codepoint_valid, Cchar, (Int32,), c))

# utf8 category constants
const UTF8PROC_CATEGORY_LU = 1
const UTF8PROC_CATEGORY_LL = 2
const UTF8PROC_CATEGORY_LT = 3
const UTF8PROC_CATEGORY_LM = 4
const UTF8PROC_CATEGORY_LO = 5
const UTF8PROC_CATEGORY_MN = 6
const UTF8PROC_CATEGORY_MC = 7
const UTF8PROC_CATEGORY_ME = 8
const UTF8PROC_CATEGORY_ND = 9
const UTF8PROC_CATEGORY_NL = 10
const UTF8PROC_CATEGORY_NO = 11
const UTF8PROC_CATEGORY_PC = 12
const UTF8PROC_CATEGORY_PD = 13
const UTF8PROC_CATEGORY_PS = 14
const UTF8PROC_CATEGORY_PE = 15
const UTF8PROC_CATEGORY_PI = 16
const UTF8PROC_CATEGORY_PF = 17
const UTF8PROC_CATEGORY_PO = 18
const UTF8PROC_CATEGORY_SM = 19
const UTF8PROC_CATEGORY_SC = 20
const UTF8PROC_CATEGORY_SK = 21
const UTF8PROC_CATEGORY_SO = 22
const UTF8PROC_CATEGORY_ZS = 23
const UTF8PROC_CATEGORY_ZL = 24
const UTF8PROC_CATEGORY_ZP = 25
const UTF8PROC_CATEGORY_CC = 26
const UTF8PROC_CATEGORY_CF = 27
const UTF8PROC_CATEGORY_CS = 28
const UTF8PROC_CATEGORY_CO = 29
const UTF8PROC_CATEGORY_CN = 30

const UTF8PROC_NULLTERM = (1<<0)
const UTF8PROC_STABLE = (1<<1)
const UTF8PROC_COMPAT = (1<<2)
Expand Down
Loading

0 comments on commit be1aa2d

Please sign in to comment.