From ff2fa916ab0e05fc822456130d711a29bd824d30 Mon Sep 17 00:00:00 2001 From: morris25 Date: Fri, 14 Sep 2018 09:41:28 -0500 Subject: [PATCH] Updates to work with julia v1.0 --- deps/build.jl | 5 +++-- src/stream_compression.jl | 4 ++-- test/lz4frame.jl | 20 ++++++++++---------- test/stream_compression.jl | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/deps/build.jl b/deps/build.jl index 79a3793..1e0a9ae 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,5 +1,6 @@ using BinDeps using Compat.Libdl +using Compat.Sys: isapple, iswindows @BinDeps.setup function validate_lz4(name,handle) @@ -14,7 +15,7 @@ short_version = "1.8.1" zipname = "lz4_v$(replace(short_version, "." => "_"))_win$(Sys.WORD_SIZE).zip" suffix = "so.$short_version" -if Sys.is_apple() +if isapple() suffix = "$short_version.$(Libdl.dlext)" end @@ -50,7 +51,7 @@ provides(BuildProcess, end end), liblz4, os = :Windows) -if Sys.is_windows() +if iswindows() push!(BinDeps.defaults, BuildProcess) @BinDeps.install Dict(:liblz4 => :liblz4) pop!(BinDeps.defaults) diff --git a/src/stream_compression.jl b/src/stream_compression.jl index fa4774b..c764cd1 100644 --- a/src/stream_compression.jl +++ b/src/stream_compression.jl @@ -32,7 +32,7 @@ function LZ4Compressor(; kwargs...) ctx = Ref{Ptr{LZ4F_cctx}}(C_NULL) frame = LZ4F_frameInfo_t(; y...) prefs = Ref(LZ4F_preferences_t(frame; x...)) - return LZ4Compressor(ctx, prefs, Memory(Vector{UInt8}(uninitialized, LZ4F_HEADER_SIZE_MAX)), false) + return LZ4Compressor(ctx, prefs, Memory(Vector{UInt8}(undef, LZ4F_HEADER_SIZE_MAX)), false) end const LZ4CompressorStream{S} = TranscodingStream{LZ4Compressor,S} where S<:IO @@ -83,7 +83,7 @@ Creates the LZ4F header to be written to the output. """ function TranscodingStreams.startproc(codec::LZ4Compressor, mode::Symbol, error::Error)::Symbol try - header = Vector{UInt8}(uninitialized, LZ4F_HEADER_SIZE_MAX) + header = Vector{UInt8}(undef, LZ4F_HEADER_SIZE_MAX) headerSize = LZ4F_compressBegin(codec.ctx[], header, convert(Csize_t, LZ4F_HEADER_SIZE_MAX), codec.prefs) codec.header = Memory(resize!(header, headerSize)) codec.write_header = true diff --git a/test/lz4frame.jl b/test/lz4frame.jl index 0cedbc0..4d7ef17 100644 --- a/test/lz4frame.jl +++ b/test/lz4frame.jl @@ -9,14 +9,14 @@ using Compat no_error = UInt(0) @test !CodecLz4.LZ4F_isError(no_error) @test CodecLz4.LZ4F_getErrorName(no_error) == "Unspecified error code" - + ERROR_GENERIC = typemax(UInt) @test CodecLz4.LZ4F_isError(ERROR_GENERIC) @test CodecLz4.LZ4F_getErrorName(ERROR_GENERIC) == "ERROR_GENERIC" end @testset "keywords" begin - + frame = CodecLz4.LZ4F_frameInfo_t() @test frame.blockSizeID == Cuint(default_size) @test frame.blockMode == Cuint(block_linked) @@ -99,7 +99,7 @@ using Compat dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL) srcsize = Ref{Csize_t}(origsize) dstsize = Ref{Csize_t}(8*1280) - decbuffer = Vector{UInt8}(uninitialized, 1280) + decbuffer = Vector{UInt8}(undef, 1280) frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t()) @@ -128,13 +128,13 @@ using Compat dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL) srcsize = Ref{Csize_t}(origsize) dstsize = Ref{Csize_t}(1280) - decbuffer = Vector{UInt8}(uninitialized, 1280) + decbuffer = Vector{UInt8}(undef, 1280) frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t()) CodecLz4.LZ4F_createDecompressionContext(dctx, version) - buffer[1:CodecLz4.LZ4F_HEADER_SIZE_MAX] = 0x10 + buffer[1:CodecLz4.LZ4F_HEADER_SIZE_MAX] .= 0x10 @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_getFrameInfo(dctx[], frameinfo, buffer, srcsize) offset = srcsize[] @@ -158,7 +158,7 @@ using Compat @test bound > 0 bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX - buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8)) + buffer = Vector{UInt8}(undef, ceil(Int, bound / 8)) @test_nowarn result = CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs) @@ -187,7 +187,7 @@ using Compat prefs = Ptr{CodecLz4.LZ4F_preferences_t}(C_NULL) bufsize = test_size - buffer = Vector{UInt8}(uninitialized, test_size) + buffer = Vector{UInt8}(undef, test_size) @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs) @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressUpdate(ctx[], pointer(buffer), bufsize, pointer(testIn), test_size, C_NULL) @@ -205,7 +205,7 @@ using Compat @test bound > 0 bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX - buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8)) + buffer = Vector{UInt8}(undef, ceil(Int, bound / 8)) @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressBegin(ctx[], buffer, UInt(2), prefs) @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_compressUpdate(ctx[], pointer(buffer), bufsize, pointer(testIn), test_size, C_NULL) @@ -233,7 +233,7 @@ using Compat dctx = Ref{Ptr{CodecLz4.LZ4F_dctx}}(C_NULL) srcsize = Ref{Csize_t}(test_size) dstsize = Ref{Csize_t}(8*1280) - decbuffer = Vector{UInt8}(uninitialized, 1280) + decbuffer = Vector{UInt8}(undef, 1280) frameinfo = Ref(CodecLz4.LZ4F_frameInfo_t()) @test_throws CodecLz4.LZ4Exception CodecLz4.LZ4F_getFrameInfo(dctx[], frameinfo, pointer(testIn), srcsize) @@ -251,7 +251,7 @@ using Compat @test bound > 0 bufsize = bound + CodecLz4.LZ4F_HEADER_SIZE_MAX - buffer = Vector{UInt8}(uninitialized, ceil(Int, bound / 8)) + buffer = Vector{UInt8}(undef, ceil(Int, bound / 8)) @test_nowarn result = CodecLz4.LZ4F_compressBegin(ctx[], buffer, bufsize, prefs) diff --git a/test/stream_compression.jl b/test/stream_compression.jl index 33808e4..9df4e1f 100644 --- a/test/stream_compression.jl +++ b/test/stream_compression.jl @@ -55,7 +55,7 @@ end @testset "Errors" begin input = Memory(Vector{UInt8}(text)) - output = Memory(Vector{UInt8}(uninitialized, 1280)) + output = Memory(Vector{UInt8}(undef, 1280)) not_initialized = LZ4Compressor() @test TranscodingStreams.startproc(not_initialized, :read, Error()) == :error @test TranscodingStreams.process(not_initialized, input, output, Error()) == (0, 0, :error) @@ -68,7 +68,7 @@ end @test_throws CodecLz4.LZ4Exception read(stream) @test_throws ArgumentError read(stream) - output = Memory(Vector{UInt8}(uninitialized, 1)) + output = Memory(Vector{UInt8}(undef, 1)) compressor = LZ4Compressor() @test_nowarn TranscodingStreams.initialize(compressor) @test TranscodingStreams.startproc(compressor, :read, Error()) == :ok @@ -108,4 +108,4 @@ end @test frame.contentSize == Culonglong(100) @test frame.blockChecksumFlag == Cuint(1) -end \ No newline at end of file +end