Skip to content

Commit

Permalink
Union() -> Union{}
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Sep 20, 2015
1 parent 804e065 commit 5100bd6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/PyCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end
pyisinstance(o::PyObject, t::PyObject) =
t.o != C_NULL && ccall((@pysym :PyObject_IsInstance), Cint, (PyPtr,PyPtr), o, t.o) == 1

pyisinstance(o::PyObject, t::Union(Ptr{Void},PyPtr)) =
@compat pyisinstance(o::PyObject, t::Union{Ptr{Void},PyPtr}) =
t != C_NULL && ccall((@pysym :PyObject_IsInstance), Cint, (PyPtr,PyPtr), o, t) == 1

pyquery(q::Ptr{Void}, o::PyObject) =
Expand Down Expand Up @@ -374,9 +374,9 @@ end

#########################################################################

typealias TypeTuple{N} Union(Type,NTuple{N, Type})
@compat typealias TypeTuple{N} Union{Type,NTuple{N, Type}}

function pycall(o::Union(PyObject,PyPtr), returntype::TypeTuple, args...; kwargs...)
@compat function pycall(o::Union{PyObject,PyPtr}, returntype::TypeTuple, args...; kwargs...)
oargs = map(PyObject, args)
nargs = length(args)
sigatomic_begin()
Expand Down
4 changes: 2 additions & 2 deletions src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ convert{T<:Integer}(::Type{T}, po::PyObject) =
convert(T, @pycheck ccall(@pysym(PyInt_AsSsize_t), Int, (PyPtr,), asscalar(po)))

if WORD_SIZE == 32
convert{T<:Union(Int64,UInt64)}(::Type{T}, po::PyObject) =
@compat convert{T<:Union{Int64,UInt64}}(::Type{T}, po::PyObject) =
@pycheck ccall((@pysym :PyLong_AsLongLong), T, (PyPtr,), asscalar(po))
end

Expand Down Expand Up @@ -159,7 +159,7 @@ pyptr_query(po::PyObject) = pyisinstance(po, c_void_p_Type) || pyisinstance(po,

# I want to use a union, but this seems to confuse Julia's method
# dispatch for the convert function in some circumstances
# typealias PyAny Union(PyObject, Int, Bool, Float64, Complex128, AbstractString, Function, Dict, Tuple, Array)
# typealias PyAny Union{PyObject, Int, Bool, Float64, Complex128, AbstractString, Function, Dict, Tuple, Array}
abstract PyAny

if VERSION < v"0.4.0-dev+4319" # prior to 0.4 tuple-type changes
Expand Down
2 changes: 1 addition & 1 deletion src/numpy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ npy_type(::Type{Complex64}) = NPY_CFLOAT
npy_type(::Type{Complex128}) = NPY_CDOUBLE
npy_type(::Type{PyPtr}) = NPY_OBJECT

typealias NPY_TYPES Union(Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float32,Float64,Complex64,Complex128,PyPtr)
@compat typealias NPY_TYPES Union{Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float32,Float64,Complex64,Complex128,PyPtr}

# conversions from __array_interface__ type strings to supported Julia types
const npy_typestrs = @compat Dict( "b1"=>Bool,
Expand Down
6 changes: 3 additions & 3 deletions src/pybuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function Base.stride(b::PyBuffer, d::Integer)
return @compat Int(unsafe_load(b.buf.strides, d))
end

iscontiguous(b::PyBuffer) =
iscontiguous(b::PyBuffer) =
1 == ccall((@pysym :PyBuffer_IsContiguous), Cint,
(Ptr{PyBuffer}, Cchar), &b, 'A')

Expand All @@ -103,14 +103,14 @@ const PyBUF_ANY_CONTIGUOUS = convert(Cint, 0x0080) | PyBUF_STRIDES
const PyBUF_INDIRECT = convert(Cint, 0x0100) | PyBUF_STRIDES

# construct a PyBuffer from a PyObject, if possible
function PyBuffer(o::Union(PyObject,PyPtr), flags=PyBUF_SIMPLE)
@compat function PyBuffer(o::Union{PyObject,PyPtr}, flags=PyBUF_SIMPLE)
b = PyBuffer()
@pycheckz ccall((@pysym :PyObject_GetBuffer), Cint,
(PyPtr, Ptr{PyBuffer}, Cint), o, &b, flags)
return b
end

#############################################################################
#############################################################################

# recursive function to write buffer dimension by dimension, starting at
# dimension d with the given pointer offset (in bytes).
Expand Down

0 comments on commit 5100bd6

Please sign in to comment.