switches to 1-based indexing for argument access

This commit is contained in:
Spencer Russell 2015-07-16 09:46:37 -04:00
parent 67c26b7742
commit 4647ab2686
2 changed files with 20 additions and 20 deletions

View File

@ -55,8 +55,8 @@ has_reserved(typeChar::Char) = typeChar in "isbfhtdSrmc"
nreserved(args::ASCIIString) = sum(map(has_reserved, collect(args))) nreserved(args::ASCIIString) = sum(map(has_reserved, collect(args)))
function argType(msg::OscMsg, nargument::Int)#::Char function argType(msg::OscMsg, nargument::Int)#::Char
@assert(nargument < narguments(msg)); @assert(nargument > 0 && nargument <= narguments(msg));
return strip_args(names(msg))[nargument+1] return strip_args(names(msg))[nargument]
end end
align(pos) = pos+(4-(pos-1)%4) align(pos) = pos+(4-(pos-1)%4)
@ -80,7 +80,7 @@ function arg_off(msg::OscMsg, idx::Int)#::Int
#ignore any leading '[' or ']' #ignore any leading '[' or ']'
while(args[argc] in "[]") argc += 1 end while(args[argc] in "[]") argc += 1 end
while(idx != 0) while(idx != 1)
bundle_length::Uint32 = 0; bundle_length::Uint32 = 0;
arg = args[argc] arg = args[argc]
argc += 1 argc += 1
@ -307,8 +307,8 @@ function showField(io::IO, msg::OscMsg, arg_id)
'F' false; 'N' Nothing] 'F' false; 'N' Nothing]
dict = Dict{Char, Any}(map[:,1][:],map[:,2][:]) dict = Dict{Char, Any}(map[:,1][:],map[:,2][:])
dict['I'] = Inf dict['I'] = Inf
typeChar::Char = argType(msg, arg_id-1) typeChar::Char = argType(msg, arg_id)
value = msg[arg_id-1] value = msg[arg_id]
if(issubtype(typeof(value), Array)) if(issubtype(typeof(value), Array))
value = value' value = value'
end end

View File

@ -61,21 +61,21 @@ function test_it_fat()
#println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), buffer[1:len])...)) #println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), buffer[1:len])...))
#println("argument string is=", rtosc_argument_string(buffer)) #println("argument string is=", rtosc_argument_string(buffer))
@test msg[0] == i @test msg[1] == i
@test msg[1] == f @test msg[2] == f
@test msg[2] == s @test msg[3] == s
@test OSC.stringify(msg[3]) == b @test OSC.stringify(msg[4]) == b
@test msg[4] == h @test msg[5] == h
@test msg[5] == t @test msg[6] == t
@test msg[6] == d @test msg[7] == d
@test msg[7] == S @test msg[8] == S
@test msg[8] == c @test msg[9] == c
@test msg[9] == r @test msg[10] == r
@test msg[10] == m @test msg[11] == m
@test OSC.argType(msg,11) == 'T' @test OSC.argType(msg,12) == 'T'
@test OSC.argType(msg,12) == 'F' @test OSC.argType(msg,13) == 'F'
@test OSC.argType(msg,13) == 'N' @test OSC.argType(msg,14) == 'N'
@test OSC.argType(msg,14) == 'I' @test OSC.argType(msg,15) == 'I'
end end
function test_it_osc_spec() function test_it_osc_spec()