summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/grph-mem.lua
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-09 20:47:50 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-09 20:47:50 +0200
commitbe735a865e2bdc6b7ac57161a24e4911741024f1 (patch)
tree583ffc0d91324da3b4f1239449bbcdf8e28a8ec3 /tex/context/base/mkiv/grph-mem.lua
parent4e4dcdd6d58631f6b260dbc16007152ac14d9677 (diff)
downloadcontext-be735a865e2bdc6b7ac57161a24e4911741024f1.tar.gz
2016-06-09 19:28:00
Diffstat (limited to 'tex/context/base/mkiv/grph-mem.lua')
-rw-r--r--tex/context/base/mkiv/grph-mem.lua51
1 files changed, 39 insertions, 12 deletions
diff --git a/tex/context/base/mkiv/grph-mem.lua b/tex/context/base/mkiv/grph-mem.lua
index 80a6bfdbf..b1ca1a15d 100644
--- a/tex/context/base/mkiv/grph-mem.lua
+++ b/tex/context/base/mkiv/grph-mem.lua
@@ -19,44 +19,71 @@ local report = logs.reporter("memstream")
local data = { }
local trace = false
+local opened = { }
+
function resolvers.finders.memstream(specification)
- local original = specification.original
- local identifier = data[original]
+ local name = specification.path
+ local identifier = data[name]
if identifier then
if trace then
report("reusing %a",identifier)
end
return identifier
end
- local stream = io.loaddata(specification.path)
+ local stream = io.loaddata(name)
if not stream or stream == "" then
return resolvers.finders.notfound()
end
- local memstream = { epdf.openMemStream(stream,#stream,original) }
- local identifier = memstream[2]
+ local memstream, identifier = epdf.openMemStream(stream,#stream,original)
if not identifier then
report("invalid %a",name)
identifier = "invalid-memstream"
elseif trace then
report("using %a",identifier)
end
- data[original] = identifier
+ data [name] = identifier
+ opened[name] = memstream
return identifier
end
-function resolvers.setmemstream(name,stream)
- local original = "memstream:///" .. name
- local memstream = { epdf.openMemStream(stream,#stream,original) }
- local identifier = memstream[2]
+function resolvers.setmemstream(name,stream,once)
+ if once and data[name] then
+ if trace then
+ report("not overloading %a",name) --
+ end
+ return
+ end
+ local memstream, identifier = epdf.openMemStream(stream,#stream,name)
if not identifier then
report("invalid %a",name)
identifier = "invalid-memstream"
elseif trace then
- report("setting %a",identifier)
+ report("setting %a as %a",name,identifier)
+ end
+ data [name] = identifier
+ opened[name] = memstream
+end
+
+local flush = { }
+
+function resolvers.resetmemstream(name,afterpage)
+ if afterpage then
+ flush[#flush+1] = name
+ else
+ opened[name] = nil
end
- data[original] = identifier
end
+luatex.registerpageactions(function()
+ if #flush > 0 then
+ for i=1,#flush do
+ opened[flush[i]] = nil -- we keep of course data[name] because of reuse
+ end
+ flush = { }
+ end
+end)
+
+
figures.identifiers.list[#figures.identifiers.list+1] = function(specification)
local name = specification.request.name
if name and data[name] then