-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathReexport.jl
34 lines (28 loc) · 949 Bytes
/
Reexport.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Reexport
macro reexport(ex)
isa(ex, Expr) && (ex.head == :module ||
ex.head == :using ||
(ex.head == :toplevel &&
all(e->isa(e, Expr) && e.head == :using, ex.args))) ||
error("@reexport: syntax error")
# if ex.head == :module
# modules = {ex.args[2]}
# ex = Expr(:toplevel, ex, Expr(:using, :., ex.args[2]))
# elseif ex.head == :using
# modules = {ex.args[end]}
# else
# modules = {e.args[end] for e in ex.args}
# end
if ex.head == :module
modules = Any[ex.args[2]]
ex = Expr(:toplevel, ex, Expr(:using, :., ex.args[2]))
elseif ex.head == :using
modules = Any[ex.args[end]]
else
modules = Any[e.args[end] for e in ex.args]
end
esc(Expr(:toplevel, ex,
[:(eval(Expr(:export, names($(mod))...))) for mod in modules]...))
end
export @reexport
end # module