Skip to content

Commit 761b103

Browse files
committed
Import from Base
1 parent 42c2c11 commit 761b103

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/APITools.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Licensed under MIT License, see LICENSE.md
88
(@def macro "stolen" from DiffEqBase.jl/src/util.jl :-) )
99
"""
1010
module APITools
11+
12+
const V6_COMPAT = VERSION < v"0.7.0-DEV"
13+
1114
export @api, @def
1215

1316
macro def(name, definition)
@@ -69,7 +72,7 @@ macro api(cmd::Symbol)
6972
global __tmp_chain__ = Vector{APITools.API}[]
7073
end
7174
elseif cmd == :freeze
72-
@static if VERSION < v"0.7.0-DEV"
75+
@static if V6_COMPAT
7376
esc(quote
7477
const __chain__ = APITools.APIList(__tmp_chain__)
7578
const __api__ = APITools.API(current_module(), __tmp_api__)
@@ -90,9 +93,8 @@ end
9093
const _cmdadd = (:define_public, :define_develop, :public, :develop, :base)
9194
const _cmduse = (:use, :test, :extend, :export)
9295

93-
@static VERSION < v"0.7.0-DEV" && (const _ff = findfirst)
94-
@static VERSION < v"0.7.0-DEV" ||
95-
(_ff(lst, val) = coalesce(findfirst(isequal(val), lst), 0))
96+
@static V6_COMPAT && (const _ff = findfirst)
97+
@static V6_COMPAT || (_ff(lst, val) = coalesce(findfirst(isequal(val), lst), 0))
9698

9799
function _add_symbols(grp, exprs)
98100
symbols = Symbol[]
@@ -105,7 +107,17 @@ function _add_symbols(grp, exprs)
105107
error("@api $grp: syntax error $ex")
106108
end
107109
end
108-
esc(:( append!(__tmp_api__.$grp, $symbols) ))
110+
if grp == :base
111+
syms = SymList(symbols)
112+
expr = "APITools._make_list($(QuoteNode(:import)), $(QuoteNode(:Base)), $syms)"
113+
parsed = Meta.parse(expr)
114+
dump(parsed)
115+
Expr(:toplevel,
116+
V6_COMPAT ? :(eval(current_module(), $parsed)) : :(eval(@__MODULE__, $parsed)),
117+
esc(:( append!(__tmp_api__.$grp, $symbols))))
118+
else
119+
esc(:( append!(__tmp_api__.$grp, $symbols) ))
120+
end
109121
end
110122

111123
function _make_modules(exprs)
@@ -169,7 +181,9 @@ end
169181

170182
function _make_exprs(cmd, mod, grp)
171183
from = QuoteNode(grp == :base ? :Base : mod)
172-
:(eval($(Meta.parse("APITools._make_list($(QuoteNode(cmd)), $from, $mod.__api__.$grp)"))))
184+
x = :(eval($(Meta.parse("APITools._make_list($(QuoteNode(cmd)), $from, $mod.__api__.$grp)"))))
185+
println("_make_exprs($cmd, $mod, $grp) => $x")
186+
x
173187
end
174188

175189
end # module APITools

0 commit comments

Comments
 (0)