summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/core-two.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2018-08-15 09:54:36 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2018-08-15 09:54:36 +0200
commit36a37da721032b8d02fad41f22ad717ee8136f34 (patch)
tree6481c1e6fca21c63679c03ad66800d505334c7b8 /tex/context/base/mkiv/core-two.lua
parent1ef7a093aaf03b6327b3da94d47f53760c868c60 (diff)
downloadcontext-36a37da721032b8d02fad41f22ad717ee8136f34.tar.gz
2018-08-14 23:17:00
Diffstat (limited to 'tex/context/base/mkiv/core-two.lua')
-rw-r--r--tex/context/base/mkiv/core-two.lua93
1 files changed, 55 insertions, 38 deletions
diff --git a/tex/context/base/mkiv/core-two.lua b/tex/context/base/mkiv/core-two.lua
index 1e59004be..3ab2112b9 100644
--- a/tex/context/base/mkiv/core-two.lua
+++ b/tex/context/base/mkiv/core-two.lua
@@ -32,7 +32,7 @@ end
job.register('job.passes.collected', tobesaved, initializer, nil)
-local function allocate(id)
+local function define(id)
local p = tobesaved[id]
if not p then
p = { }
@@ -41,10 +41,8 @@ local function allocate(id)
return p
end
-jobpasses.define = allocate
-
-function jobpasses.save(id,str,index)
- local jti = allocate(id)
+local function save(id,str,index)
+ local jti = define(id)
if index then
jti[index] = str
else
@@ -52,30 +50,30 @@ function jobpasses.save(id,str,index)
end
end
-function jobpasses.savetagged(id,tag,str)
- local jti = allocate(id)
+local function savetagged(id,tag,str)
+ local jti = define(id)
jti[tag] = str
end
-function jobpasses.getdata(id,index,default)
+local function getdata(id,index,default)
local jti = collected[id]
local value = jti and jti[index]
return value ~= "" and value or default or ""
end
-function jobpasses.getfield(id,index,tag,default)
+local function getfield(id,index,tag,default)
local jti = collected[id]
jti = jti and jti[index]
local value = jti and jti[tag]
return value ~= "" and value or default or ""
end
-function jobpasses.getcollected(id)
+local function getcollected(id)
return collected[id] or { }
end
-function jobpasses.gettobesaved(id)
- return allocate(id)
+local function gettobesaved(id)
+ return define(id)
end
local function get(id)
@@ -87,23 +85,17 @@ end
local function first(id)
local jti = collected[id]
- if jti and #jti > 0 then
- return jti[1]
- end
+ return jti and jti[1]
end
local function last(id)
local jti = collected[id]
- if jti and #jti > 0 then
- return jti[#jti]
- end
+ return jti and jti[#jti]
end
local function find(id,n)
local jti = collected[id]
- if jti and jti[n] then
- return jti[n]
- end
+ return jti and jti[n] or nil
end
local function count(id)
@@ -132,44 +124,49 @@ end
local check = first
---
-
-jobpasses.get = get
-jobpasses.first = first
-jobpasses.last = last
-jobpasses.find = find
-jobpasses.list = list
-jobpasses.count = count
-jobpasses.check = check
-jobpasses.inlist = inlist
+jobpasses.define = define
+jobpasses.save = save
+jobpasses.savetagged = savetagged
+jobpasses.getdata = getdata
+jobpasses.getfield = getfield
+jobpasses.getcollected = getcollected
+jobpasses.gettobesaved = gettobesaved
+jobpasses.get = get
+jobpasses.first = first
+jobpasses.last = last
+jobpasses.find = find
+jobpasses.list = list
+jobpasses.count = count
+jobpasses.check = check
+jobpasses.inlist = inlist
-- interface
local implement = interfaces.implement
-implement { name = "gettwopassdata", actions = { get , context }, arguments = "string" }
+implement { name = "gettwopassdata", actions = { get, context }, arguments = "string" }
implement { name = "getfirsttwopassdata",actions = { first, context }, arguments = "string" }
-implement { name = "getlasttwopassdata", actions = { last , context }, arguments = "string" }
-implement { name = "findtwopassdata", actions = { find , context }, arguments = "2 strings" }
-implement { name = "gettwopassdatalist", actions = { list , context }, arguments = "string" }
+implement { name = "getlasttwopassdata", actions = { last, context }, arguments = "string" }
+implement { name = "findtwopassdata", actions = { find, context }, arguments = "2 strings" }
+implement { name = "gettwopassdatalist", actions = { list, context }, arguments = "string" }
implement { name = "counttwopassdata", actions = { count, context }, arguments = "string" }
implement { name = "checktwopassdata", actions = { check, context }, arguments = "string" }
implement {
name = "definetwopasslist",
- actions = jobpasses.define,
+ actions = define,
arguments = "string"
}
implement {
name = "savetwopassdata",
- actions = jobpasses.save,
+ actions = save,
arguments = "2 strings",
}
implement {
name = "savetaggedtwopassdata",
- actions = jobpasses.savetagged,
+ actions = savetagged,
arguments = "3 strings",
}
@@ -178,3 +175,23 @@ implement {
actions = { inlist, commands.doifelse },
arguments = "2 strings",
}
+
+-- local ctx_latelua = context.latelua
+
+-- implement {
+-- name = "lazysavetwopassdata",
+-- arguments = "3 strings",
+-- public = true,
+-- actions = function(a,b,c)
+-- ctx_latelua(function() save(a,c) end)
+-- end,
+-- }
+
+-- implement {
+-- name = "lazysavetaggedtwopassdata",
+-- arguments = "3 strings",
+-- public = true,
+-- actions = function(a,b,c)
+-- ctx_latelua(function() savetagged(a,b,c) end)
+-- end,
+-- }