From b8800b0d05e37ece9dd29cc71a6913e3b67469e3 Mon Sep 17 00:00:00 2001 From: fundamental Date: Sun, 9 Sep 2018 12:26:05 -0400 Subject: [PATCH] Fix 0.7 errors/warnings --- src/OSC.jl | 12 ++++++------ test/runtests.jl | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/OSC.jl b/src/OSC.jl index 01c5cc1..1ead52e 100644 --- a/src/OSC.jl +++ b/src/OSC.jl @@ -33,7 +33,7 @@ end path(msg::OscMsg) = stringify(msg.data) function stringify(data::Array{UInt8}) - zeroInd = find(data.== 0) + zeroInd = findall(data.== 0) if length(zeroInd) == 0 return string(map(Char, data)...) elseif zeroInd[1] == 0 @@ -50,7 +50,7 @@ function names(msg::OscMsg) #::String return stringify(msg.data[pos+1:end]) #skip comma end -strip_args(args::AbstractString) = replace(replace(args,"]",""),"[","") +strip_args(args::AbstractString) = replace(replace(args,"]"=>""),"["=>"") function narguments(msg::OscMsg) length(strip_args(names(msg))) @@ -229,7 +229,7 @@ function message(address::String, arguments::String, args...) len::Int = vsosc_null(address, arguments, args...) - data::Vector{UInt8} = Array{UInt8}(len) + data::Vector{UInt8} = Array{UInt8}(undef, len) rtosc_amessage(data,len,address,arguments,args...) return OscMsg(data) end @@ -264,7 +264,7 @@ function rtosc_argument(msg::OscMsg, idx::Int) return t end elseif typeChar in "f" - return read(IOBuffer(msg.data[arg_pos+(3:-1:0)]), Float32) + return read(IOBuffer(msg.data[arg_pos.+(3:-1:0)]), Float32) elseif typeChar in "rci" i::UInt32 = 0 i |= (UInt32(msg.data[@incfp(arg_pos)]) << 24) @@ -274,7 +274,7 @@ function rtosc_argument(msg::OscMsg, idx::Int) if typeChar == 'r' return UInt32(i) elseif typeChar == 'c' - return Char(i) + return Char(i/(2^24)) else return reinterpret(Int32, i) end @@ -291,7 +291,7 @@ function rtosc_argument(msg::OscMsg, idx::Int) len |= (msg.data[@incfp(arg_pos)] << 16) len |= (msg.data[@incfp(arg_pos)] << 8) len |= (msg.data[@incfp(arg_pos)]) - return msg.data[arg_pos+(0:len-1)] + return msg.data[arg_pos.+(0:len-1)] elseif typeChar in "Ss" return stringify(msg.data[arg_pos:end]) end diff --git a/test/runtests.jl b/test/runtests.jl index 392fca1..83a947c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -105,8 +105,8 @@ function test_it_osc_spec() osc=OscMsg("/oscillator/4/frequency", "f", Float32(440.0)) - println(string(map(x->(hex(x,2)), osc.data)...)) - println(string(map(x->(hex(x,2)), message_one)...)) + println(string(map(x->(string(x,base=16, pad=2)), osc.data)...)) + println(string(map(x->(string(x,base=16, pad=2)), message_one)...)) println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), osc.data)...)) println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), message_one)...)) @test length(osc.data) == length(message_one) @@ -114,8 +114,8 @@ function test_it_osc_spec() show(osc) osc = OscMsg("/foo", "iisff", Int32(1000), Int32(-1), "hello", Float32(1.234), Float32(5.678)) - println(string(map(x->(hex(x,2)), osc.data)...)) - println(string(map(x->(hex(x,2)), message_two)...)) + println(string(map(x->(string(x,base=16, pad=2)), osc.data)...)) + println(string(map(x->(string(x,base=16, pad=2)), message_two)...)) println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), osc.data)...)) println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), message_two)...)) @test length(osc.data) == length(message_two)