Last active
September 27, 2015 06:31
-
-
Save yomichi/def5921f6b81eb5f7b44 to your computer and use it in GitHub Desktop.
switch on/off deprecation warning on running.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#= | |
Yuichi Motoyama 2015 | |
This is distributed under the Boost Software License Version 1.0 | |
http://www.boost.org/LICENSE_1_0.txt | |
=# | |
@enum DepwarnFlag DepwarnOff=0 DepwarnOn=1 DepwarnError=2 | |
doc""" | |
- `switch_depwarn!(flag :: Bool)` | |
- `switch_depwarn!(flag :: DepwarnFlag)` | |
Enable/Disable deprecation warning. | |
- `DepwarnOff` or `false` : switch off deprecation warning | |
- `DepwarnOn` or `true` : switch on deprecation warning | |
- `DepwarnError` : turn deprecation warning into error | |
""" | |
switch_depwarn!(flag :: Bool) = switch_depwarn!(flag ? DepwarnOn : DepwarnOff) | |
function switch_depwarn!(flag :: DepwarnFlag) | |
old_opt = Base.JLOptions() | |
params = map(fieldnames(Base.JLOptions)) do name | |
name == :depwarn ? Int(flag) : getfield(old_opt, name) | |
end | |
new_opt = Base.JLOptions(params...) | |
unsafe_store!(cglobal(:jl_options, Base.JLOptions), new_opt) | |
flag | |
end | |
# one-liner | |
# unsafe_store!(cglobal(:jl_options, Base.JLOptions), Base.JLOptions(map(fieldnames(Base.JLOptions)) do name; name==:depwarn?0:getfield(Base.JLOptions(), name) end...)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment