Skip to content

Commit f3aa738

Browse files
committed
Make cur_mod() work for any version
1 parent e191b69 commit f3aa738

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ModuleInterfaceTools.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function Base.show(io::IO, api::AbstractAPI)
8282
end
8383

8484
"""Get current module"""
85-
cur_mod() = ccall(:jl_get_current_module, Ref{Module}, ())
85+
cur_mod() = @static V6_COMPAT ? current_module() : ccall(:jl_get_current_module, Ref{Module}, ())
8686

8787
function m_eval(mod, expr)
8888
try
@@ -122,7 +122,7 @@ end
122122
123123
"""
124124
macro api(cmd::Symbol)
125-
mod = @static V6_COMPAT ? current_module() : cur_mod()
125+
mod = cur_mod()
126126
cmd == :list ? _api_list(mod) :
127127
cmd == :freeze ? _api_freeze(mod) :
128128
cmd == :test ? _api_test(mod) :
@@ -368,6 +368,7 @@ _do_list(curmod, cpy, cmd, mod, nam, grp, api::API) =
368368
_do_list(curmod, cpy, cmd, mod, nam, grp, getfield(api, grp))
369369

370370
function _do_list(curmod, cpy, cmd, mod, nam, grp, lst)
371+
debug[] && println("_do_list($curmod, $cpy, $cmd, $mod, $nam, $grp, $lst)")
371372
for sym in lst
372373
if isdefined(mod, sym)
373374
m_eval(curmod, Expr(cmd, nam, sym))
@@ -379,7 +380,7 @@ function _do_list(curmod, cpy, cmd, mod, nam, grp, lst)
379380
end
380381

381382
macro api(cmd::Symbol, exprs...)
382-
_api((@static V6_COMPAT ? current_module() : cur_mod()), cmd, exprs)
383+
_api(cur_mod(), cmd, exprs)
383384
end
384385

385386
end # module ModuleInterfaceTools

0 commit comments

Comments
 (0)