kludge to allow hot-plug of optional backends
This commit is contained in:
parent
4c34a1df15
commit
682fa6e9e6
@ -13,6 +13,26 @@ backends() = _backends
|
||||
backend_name() = CURRENT_BACKEND.sym
|
||||
_backend_instance(sym::Symbol) = haskey(_backendType, sym) ? _backendType[sym]() : error("Unsupported backend $sym")
|
||||
|
||||
# kludge while waiting for Pkg alternatives
|
||||
if VERSION >= v"0.7-"
|
||||
function _findmod(f::Symbol)
|
||||
for (u,v) in Base.loaded_modules
|
||||
(Symbol(v) == f) && return u
|
||||
end
|
||||
nothing
|
||||
end
|
||||
function topimport(modname)
|
||||
@eval Base.__toplevel__ import $modname
|
||||
u = _findmod(modname)
|
||||
@eval $modname = Base.loaded_modules[$u]
|
||||
end
|
||||
else
|
||||
function myimport(modname)
|
||||
@eval import $modname
|
||||
end
|
||||
end
|
||||
# end kludge
|
||||
|
||||
macro init_backend(s)
|
||||
str = lowercase(string(s))
|
||||
sym = Symbol(str)
|
||||
|
||||
@ -67,7 +67,7 @@ end
|
||||
|
||||
function _initialize_backend(::GRBackend; kw...)
|
||||
@eval begin
|
||||
import GR
|
||||
topimport(:GR)
|
||||
export GR
|
||||
end
|
||||
end
|
||||
|
||||
@ -142,7 +142,7 @@ end
|
||||
|
||||
function _initialize_backend(::HDF5Backend)
|
||||
@eval begin
|
||||
import HDF5
|
||||
topimport(:HDF5)
|
||||
export HDF5
|
||||
if length(HDF5PLOT_MAP_TELEM2STR) < 1
|
||||
#Possible element types of high-level data types:
|
||||
|
||||
@ -162,7 +162,7 @@ end
|
||||
|
||||
function _initialize_backend(::InspectDRBackend; kw...)
|
||||
@eval begin
|
||||
import InspectDR
|
||||
topimport(:InspectDR)
|
||||
export InspectDR
|
||||
|
||||
#Glyph used when plotting "Shape"s:
|
||||
|
||||
@ -58,7 +58,7 @@ end
|
||||
|
||||
function _initialize_backend(::PGFPlotsBackend; kw...)
|
||||
@eval begin
|
||||
import PGFPlots
|
||||
topimport(:PGFPlots)
|
||||
export PGFPlots
|
||||
end
|
||||
end
|
||||
|
||||
@ -29,7 +29,7 @@ end
|
||||
|
||||
function _initialize_backend(::PlotlyJSBackend; kw...)
|
||||
@eval begin
|
||||
import PlotlyJS
|
||||
topimport(:PlotlyJS)
|
||||
export PlotlyJS
|
||||
end
|
||||
|
||||
|
||||
@ -77,8 +77,12 @@ function _initialize_backend(::PyPlotBackend)
|
||||
# problem: https://github.com/tbreloff/Plots.jl/issues/308
|
||||
# solution: hack from @stevengj: https://github.com/stevengj/PyPlot.jl/pull/223#issuecomment-229747768
|
||||
otherdisplays = splice!(Base.Multimedia.displays, 2:length(Base.Multimedia.displays))
|
||||
import PyPlot, PyCall
|
||||
import LaTeXStrings: latexstring
|
||||
|
||||
topimport(:PyPlot)
|
||||
topimport(:PyCall)
|
||||
topimport(:LaTeXStrings)
|
||||
latexstring = LaTeXStrings.latexstring
|
||||
|
||||
append!(Base.Multimedia.displays, otherdisplays)
|
||||
|
||||
export PyPlot
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
function _initialize_backend(::[PkgName]Backend; kw...)
|
||||
@eval begin
|
||||
import [PkgName]
|
||||
topimport(:[PkgName])
|
||||
export [PkgName]
|
||||
# todo: other initialization that needs to be eval-ed
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ end
|
||||
|
||||
function _initialize_backend(::UnicodePlotsBackend; kw...)
|
||||
@eval begin
|
||||
import UnicodePlots
|
||||
topimport(:UnicodePlots)
|
||||
export UnicodePlots
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user