@@ -2,7 +2,7 @@ __precompile__(true)
2
2
"""
3
3
API Tools package
4
4
5
- Copyright 2018 Gandalf Software, Inc., Scott P. Jones
5
+ Copyright 2018-2019 Gandalf Software, Inc., Scott P. Jones
6
6
7
7
Licensed under MIT License, see LICENSE.md
8
8
@@ -16,8 +16,8 @@ const showeval = Ref(false)
16
16
const V6_COMPAT = VERSION < v " 0.7-"
17
17
const BIG_ENDIAN = (ENDIAN_BOM == 0x01020304 )
18
18
19
- _stdout () = @static V6_COMPAT ? STDOUT : stdout
20
- _stderr () = @static V6_COMPAT ? STDERR : stderr
19
+ _stdout () = stdout
20
+ _stderr () = stderr
21
21
22
22
Base. parse (:: Type{Expr} , args... ; kwargs... ) =
23
23
Meta. parse (args... ; kwargs... )
91
91
"""
92
92
@api <cmd> [<symbols>...]
93
93
94
- * freeze # use at end of module to freeze API
94
+ * freeze # use at end of module to freeze API
95
95
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)
97
97
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
104
104
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
114
114
115
115
* path <paths...> # Add paths to LOAD_PATH
116
116
117
117
* def <name> <expr> # Same as the @def macro, creates a macro with the given name
118
118
119
119
"""
120
120
macro api (cmd:: Symbol )
121
- mod = @static V6_COMPAT ? current_module () : __module__
121
+ mod = __module__
122
122
cmd == :list ? _api_list (mod) :
123
123
cmd == :freeze ? _api_freeze (mod) :
124
124
cmd == :test ? _api_test (mod) :
@@ -163,12 +163,11 @@ function _api_path(curmod, exprs)
163
163
nothing
164
164
end
165
165
166
- const _cmduse = (:use , :use! , :test , :extend , :extend! , :export , :list )
166
+ const _cmduse = (:use , :use! , :test , :extend , :extend! , :reexport , :list )
167
167
const _cmdadd =
168
168
(:modules , :public , :develop , :public! , :develop! , :base , :base! , :define! , :defdev! )
169
169
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)
172
171
173
172
function _add_def! (curmod, grp, exp)
174
173
debug[] && print (" _add_def!($curmod , $grp , $exp ::$(typeof (exp)) " )
@@ -287,7 +286,7 @@ function _api_use(curmod, modules, cpy::Bool)
287
286
nothing
288
287
end
289
288
290
- function _api_export (curmod, modules)
289
+ function _api_reexport (curmod, modules)
291
290
for nam in modules
292
291
mod = m_eval (curmod, nam)
293
292
if has_api (mod)
@@ -307,7 +306,7 @@ function _api_list(curmod, modules)
307
306
nothing
308
307
end
309
308
310
- _api_test (mod) = m_eval (mod, V6_COMPAT ? :( using Base . Test) : :(using Test))
309
+ _api_test (mod) = m_eval (mod, :(using Test))
311
310
312
311
function _api (curmod:: Module , cmd:: Symbol , exprs)
313
312
cmd == :def && return _api_def (exprs... )
@@ -346,7 +345,7 @@ function _api(curmod::Module, cmd::Symbol, exprs)
346
345
end
347
346
debug[] && println (" => $modules " )
348
347
349
- cmd == :export && return _api_export (curmod, modules)
348
+ cmd == :reexport && return _api_reexport (curmod, modules)
350
349
cmd == :list && return _api_list (curmod, modules)
351
350
352
351
cpy = (cmd == :use! ) || (cmd == :extend! )
@@ -373,13 +372,9 @@ function _api(curmod::Module, cmd::Symbol, exprs)
373
372
end
374
373
375
374
function 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)))
383
378
end
384
379
385
380
_do_list (curmod, cpy, cmd, mod, nam, grp, api:: API ) =
@@ -398,8 +393,7 @@ function _do_list(curmod, cpy, cmd, mod, nam, grp, lst)
398
393
end
399
394
400
395
macro api (cmd:: Symbol , exprs... )
401
- mod = @static V6_COMPAT ? current_module () : __module__
402
- _api (mod, cmd, exprs)
396
+ _api (__module__, cmd, exprs)
403
397
end
404
398
405
399
end # module ModuleInterfaceTools
0 commit comments