Skip to content

Commit

Permalink
Updates to work with julia v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
morris25 committed Sep 14, 2018
1 parent a882f50 commit ff2fa91
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
5 changes: 3 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BinDeps
using Compat.Libdl
using Compat.Sys: isapple, iswindows
@BinDeps.setup

function validate_lz4(name,handle)
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/stream_compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions test/lz4frame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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[]
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions test/stream_compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -108,4 +108,4 @@ end
@test frame.contentSize == Culonglong(100)
@test frame.blockChecksumFlag == Cuint(1)

end
end

0 comments on commit ff2fa91

Please sign in to comment.