Skip to content

Commit

Permalink
updated force macro to v0.7 julia
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Jun 3, 2018
1 parent 3f6f830 commit 0b7fa5a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ os:
- osx
julia:
- 0.6
- 0.7
- nightly
notifications:
email: false
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
18 changes: 14 additions & 4 deletions src/ForceImport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ macro force(use)
pkgs = use.head :using ? use.args : [use]
out = []
for p pkgs
m = p.args[end]
s = :([Expr(:import,Symbol($(string(m))),j) for j names($(esc(m)))])
w = typeof(p.args[end]) == Symbol ? [p.args[end]] : p.args[end].args
m = VERSION > v"0.7-" ? p.args[end].args[end] : p.args[end]
s = if VERSION > v"0.7-"
:([Expr(:import,Expr(:.,Symbol.($(string.(w)))...,j)) for j names($(esc(m)))])
else
:([Expr(:import,Symbol.($(string.(w)))...,j) for j names($(esc(m)))])
end
push!(out,Expr(:import,p.args...),:($(esc(:eval))(Expr(:toplevel,$s...))))
end
return Expr(:block,out...)
Expand All @@ -35,8 +40,13 @@ macro port(use)
pkgs = use.head :using ? use.args : [use]
out = []
for p pkgs
m = p.args[end]
s = :([Expr(:export,Symbol($(string(m))),j) for j names($(esc(m)))])
w = typeof(p.args[end]) == Symbol ? [p.args[end]] : p.args[end].args
m = VERSION > v"0.7-" ? p.args[end].args[end] : p.args[end]
s = if VERSION > v"0.7-"
:([Expr(:export,Expr(:.,Symbol.($(string.(w)))...,j)) for j names($(esc(m)))])
else
:([Expr(:export,Symbol.($(string.(w)))...,j) for j names($(esc(m)))])
end
push!(out,Expr(:export,p.args...),:($(esc(:eval))(Expr(:toplevel,$s...))))
end
return Expr(:block,out...)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end

module Bar
using ForceImport
@force using Foo
@force using Main.Foo
end

# write your own tests here
Expand Down

0 comments on commit 0b7fa5a

Please sign in to comment.