From b5560de0eacb160a0039473fd644495f63c719ae Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 13 Feb 2017 15:03:40 +0100 Subject: [PATCH] Fix deprecated inner-constructor syntax. Ref JuliaLang/julia#20308 --- src/array.jl | 11 +++++------ src/module/global.jl | 6 +++--- src/pointer.jl | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/array.jl b/src/array.jl index 5c84756..a5e0dcf 100644 --- a/src/array.jl +++ b/src/array.jl @@ -6,11 +6,11 @@ export ## construction -type CuArray{T,N} <: AbstractArray{T,N} +@compat type CuArray{T,N} <: AbstractArray{T,N} devptr::DevicePtr{T} shape::NTuple{N,Int} - function CuArray(shape::NTuple{N,Int}) + function (::Type{CuArray{T,N}}){T,N}(shape::NTuple{N,Int}) if !isbits(T) # non-isbits types results in an array with references to CPU objects throw(ArgumentError("CuArray with non-bit element type not supported")) @@ -21,15 +21,14 @@ type CuArray{T,N} <: AbstractArray{T,N} len = prod(shape) devptr = Mem.alloc(T, len) - obj = new(devptr, shape) + obj = new{T,N}(devptr, shape) block_finalizer(obj, devptr.ctx) finalizer(obj, finalize) return obj end - function CuArray(shape::NTuple{N,Int}, devptr::DevicePtr{T}) - new(devptr, shape) - end + (::Type{CuArray{T,N}}){T,N}(shape::NTuple{N,Int}, devptr::DevicePtr{T}) = + new{T,N}(devptr, shape) end (::Type{CuArray{T}}){T,N}(shape::NTuple{N,Int}) = CuArray{T,N}(shape) diff --git a/src/module/global.jl b/src/module/global.jl index 41bb67b..6160522 100644 --- a/src/module/global.jl +++ b/src/module/global.jl @@ -4,12 +4,12 @@ export CuGlobal, get, set -immutable CuGlobal{T} +@compat immutable CuGlobal{T} # TODO: typed pointer devptr::DevicePtr{Void} nbytes::Cssize_t - function CuGlobal(mod::CuModule, name::String) + function (::Type{CuGlobal{T}}){T}(mod::CuModule, name::String) ptr_ref = Ref{Ptr{Void}}() nbytes_ref = Ref{Cssize_t}() @apicall(:cuModuleGetGlobal, (Ptr{Ptr{Void}}, Ptr{Cssize_t}, CuModule_t, Ptr{Cchar}), @@ -19,7 +19,7 @@ immutable CuGlobal{T} end @assert nbytes_ref[] == sizeof(T) - return new(DevicePtr{Void}(ptr_ref[], CuCurrentContext()), nbytes_ref[]) + return new{T}(DevicePtr{Void}(ptr_ref[], CuCurrentContext()), nbytes_ref[]) end end diff --git a/src/pointer.jl b/src/pointer.jl index c1a03a5..0a8467a 100644 --- a/src/pointer.jl +++ b/src/pointer.jl @@ -10,11 +10,11 @@ export # It also keep track of the associated context, preventing it from getting freed while # there's still a pointer from that context live. -immutable DevicePtr{T} +@compat immutable DevicePtr{T} ptr::Ptr{T} ctx::CuContext - DevicePtr(ptr::Ptr{T}, ctx::CuContext) = new(ptr,ctx) + (::Type{DevicePtr{T}}){T}(ptr::Ptr{T}, ctx::CuContext) = new{T}(ptr,ctx) end function Base.:(==)(a::DevicePtr, b::DevicePtr)