@@ -2,7 +2,7 @@ __precompile__(true)
22"""
33API Tools package
44
5- Copyright 2018 Gandalf Software, Inc., Scott P. Jones
5+ Copyright 2018-2019 Gandalf Software, Inc., Scott P. Jones
66
77Licensed under MIT License, see LICENSE.md
88
@@ -16,8 +16,8 @@ const showeval = Ref(false)
1616const V6_COMPAT = VERSION < v " 0.7-"
1717const BIG_ENDIAN = (ENDIAN_BOM == 0x01020304 )
1818
19- _stdout () = @static V6_COMPAT ? STDOUT : stdout
20- _stderr () = @static V6_COMPAT ? STDERR : stderr
19+ _stdout () = stdout
20+ _stderr () = stderr
2121
2222Base. parse (:: Type{Expr} , args... ; kwargs... ) =
2323 Meta. parse (args... ; kwargs... )
9191"""
9292@api <cmd> [<symbols>...]
9393
94- * freeze # use at end of module to freeze API
94+ * freeze # use at end of module to freeze API
9595
96- * list <modules>... # list API(s) of given modules (or current if none given)
96+ * list <modules>... # list API(s) of given modules (or current if none given)
9797
98- * use <modules>... # use, without importing (i.e. can't extend)
99- * use! <modules>... # use, without importing (i.e. can't extend), "export"
100- * test <modules>... # using public and develop APIs, for testing purposes
101- * extend <modules>... # for development, imports api & dev, use api & dev definitions
102- * extend! <modules>... # for development, imports api & dev, use api & dev definitions, "export"
103- * export <modules>... # export public definitions
98+ * use <modules>... # use, without importing (i.e. can't extend)
99+ * use! <modules>... # use, without importing (i.e. can't extend), "export"
100+ * test <modules>... # using public and develop APIs, for testing purposes
101+ * extend <modules>... # for development, imports api & dev, use api & dev definitions
102+ * extend! <modules>... # for development, imports api & dev, use api & dev definitions, "export"
103+ * reexport <modules>... # export public definitions from those modules
104104
105- * base <names...> # Add functions from Base that are part of the API (extendible)
106- * base! <names...> # Add functions from Base or define them if not in Base
107- * public <names...> # Add other symbols that are part of the public API (structs, consts)
108- * public! <names...> # Add functions that are part of the public API (extendible)
109- * develop <names...> # Add other symbols that are part of the development API
110- * develop! <names...> # Add functions that are part of the development API (extendible)
111- * define! <names...> # Define functions to be extended, public API
112- * defdev! <names...> # Define functions to be extended, develop API
113- * modules <names...> # Add submodule names that are part of the API
105+ * base <names...> # Add functions from Base that are part of the API (extendible)
106+ * base! <names...> # Add functions from Base or define them if not in Base
107+ * public <names...> # Add other symbols that are part of the public API (structs, consts)
108+ * public! <names...> # Add functions that are part of the public API (extendible)
109+ * develop <names...> # Add other symbols that are part of the development API
110+ * develop! <names...> # Add functions that are part of the development API (extendible)
111+ * define! <names...> # Define functions to be extended, public API
112+ * defdev! <names...> # Define functions to be extended, develop API
113+ * modules <names...> # Add submodule names that are part of the API
114114
115115 * path <paths...> # Add paths to LOAD_PATH
116116
117117 * def <name> <expr> # Same as the @def macro, creates a macro with the given name
118118
119119"""
120120macro api (cmd:: Symbol )
121- mod = @static V6_COMPAT ? current_module () : __module__
121+ mod = __module__
122122 cmd == :list ? _api_list (mod) :
123123 cmd == :freeze ? _api_freeze (mod) :
124124 cmd == :test ? _api_test (mod) :
@@ -163,12 +163,11 @@ function _api_path(curmod, exprs)
163163 nothing
164164end
165165
166- const _cmduse = (:use , :use! , :test , :extend , :extend! , :export , :list )
166+ const _cmduse = (:use , :use! , :test , :extend , :extend! , :reexport , :list )
167167const _cmdadd =
168168 (:modules , :public , :develop , :public! , :develop! , :base , :base! , :define! , :defdev! )
169169
170- @static V6_COMPAT ? (const _ff = findfirst) :
171- (_ff (lst, val) = (ret = findfirst (isequal (val), lst); ret === nothing ? 0 : ret))
170+ _ff (lst, val) = (ret = findfirst (isequal (val), lst); ret === nothing ? 0 : ret)
172171
173172function _add_def! (curmod, grp, exp)
174173 debug[] && print (" _add_def!($curmod , $grp , $exp ::$(typeof (exp)) " )
@@ -287,7 +286,7 @@ function _api_use(curmod, modules, cpy::Bool)
287286 nothing
288287end
289288
290- function _api_export (curmod, modules)
289+ function _api_reexport (curmod, modules)
291290 for nam in modules
292291 mod = m_eval (curmod, nam)
293292 if has_api (mod)
@@ -307,7 +306,7 @@ function _api_list(curmod, modules)
307306 nothing
308307end
309308
310- _api_test (mod) = m_eval (mod, V6_COMPAT ? :( using Base . Test) : :(using Test))
309+ _api_test (mod) = m_eval (mod, :(using Test))
311310
312311function _api (curmod:: Module , cmd:: Symbol , exprs)
313312 cmd == :def && return _api_def (exprs... )
@@ -346,7 +345,7 @@ function _api(curmod::Module, cmd::Symbol, exprs)
346345 end
347346 debug[] && println (" => $modules " )
348347
349- cmd == :export && return _api_export (curmod, modules)
348+ cmd == :reexport && return _api_reexport (curmod, modules)
350349 cmd == :list && return _api_list (curmod, modules)
351350
352351 cpy = (cmd == :use! ) || (cmd == :extend! )
@@ -373,13 +372,9 @@ function _api(curmod::Module, cmd::Symbol, exprs)
373372end
374373
375374function makecmd (cmd, nam, sym)
376- @static if V6_COMPAT
377- Expr (cmd, nam, sym)
378- else
379- (cmd == :using
380- ? Expr (cmd, Expr (:(:), Expr (:., nam), Expr (:., sym)))
381- : Expr (cmd, Expr (:., nam, sym)))
382- end
375+ (cmd == :using
376+ ? Expr (cmd, Expr (:(:), Expr (:., nam), Expr (:., sym)))
377+ : Expr (cmd, Expr (:., nam, sym)))
383378end
384379
385380_do_list (curmod, cpy, cmd, mod, nam, grp, api:: API ) =
@@ -398,8 +393,7 @@ function _do_list(curmod, cpy, cmd, mod, nam, grp, lst)
398393end
399394
400395macro api (cmd:: Symbol , exprs... )
401- mod = @static V6_COMPAT ? current_module () : __module__
402- _api (mod, cmd, exprs)
396+ _api (__module__, cmd, exprs)
403397end
404398
405399end # module ModuleInterfaceTools
0 commit comments