From 0b7fa5a9f8f0b684f1566b032c626a98034b2ee1 Mon Sep 17 00:00:00 2001 From: Michael Reed Date: Sun, 3 Jun 2018 14:18:39 -0400 Subject: [PATCH] updated force macro to v0.7 julia --- .travis.yml | 1 + appveyor.yml | 2 ++ src/ForceImport.jl | 18 ++++++++++++++---- test/runtests.jl | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3bd4687..f7f9fbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ os: - osx julia: - 0.6 + - 0.7 - nightly notifications: email: false diff --git a/appveyor.yml b/appveyor.yml index f3fa71f..742f8f1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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" diff --git a/src/ForceImport.jl b/src/ForceImport.jl index cc7fe89..a08fb93 100644 --- a/src/ForceImport.jl +++ b/src/ForceImport.jl @@ -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...) @@ -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...) diff --git a/test/runtests.jl b/test/runtests.jl index e2b44e5..115e804 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,7 +8,7 @@ end module Bar using ForceImport - @force using Foo + @force using Main.Foo end # write your own tests here