Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility issues with v0.4 ntuple #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/Options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@ function Options{T<:OptionsChecking}(::Type{T},args...)
end
n = div(length(args),2)
keys, index, vals = if n > 0
(args[1:2:end], ntuple(n, identity), Any[args[2:2:end]...])
(args[1:2:end], ntuple(identity, n), Any[args[2:2:end]...])
else
((), (), Array(Any, 0))
end
ht = Dict{Symbol,Int}(keys,index)
if VERSION < v"0.3-"
ht = Dict{Symbol,Int}(keys,index)
else
ht = Dict{Symbol,Int}(zip(keys,index))
end
used = falses(n)
check_lock = falses(n)
Options{T}(ht,vals,used,check_lock)
end
# Constructor: supply type followed by list of assignment expressions, e.g.,
# o = Options(CheckNone,:(a=5),:(b=rand(3)),...)
function Options{T<:OptionsChecking}(::Type{T},ex::Expr...)
ht = (Symbol=>Int)[]
ht = Dict{Symbol,Int}()
vals = Array(Any,0)
n = length(ex)
for i = 1:n
Expand Down Expand Up @@ -184,7 +188,7 @@ macro defaults(opts,ex...)
exret = :($(esc(symbol(varname))) = ischeck($(esc(opts))))
# Transform the tuple into a vector, so that
# we can manipulate it
ex = {ex...}
ex = Any[ex...]
# Check each argument in the assignment list
i = 1
while i <= length(ex)
Expand Down Expand Up @@ -236,7 +240,7 @@ macro options(ex...)
callargs = Any[:Options]
# Transform the tuple into a vector, so that
# we can manipulate it
ex = {ex...}
ex = Any[ex...]
i = 1
if length(ex) >= 1 && isa(ex[1], Symbol)
push!(callargs, esc(ex[1]))
Expand Down Expand Up @@ -270,7 +274,7 @@ macro set_options(opts,ex...)
end
# Transform the tuple into a vector, so that
# we can manipulate it
ex = {ex...}
ex = Any[ex...]
# Check each argument in the assignment list
i = 1
while i <= length(ex)
Expand Down