summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/node-ppt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/node-ppt.lua')
-rw-r--r--tex/context/base/mkiv/node-ppt.lua277
1 files changed, 187 insertions, 90 deletions
diff --git a/tex/context/base/mkiv/node-ppt.lua b/tex/context/base/mkiv/node-ppt.lua
index 5ebfca87d..0124f885b 100644
--- a/tex/context/base/mkiv/node-ppt.lua
+++ b/tex/context/base/mkiv/node-ppt.lua
@@ -30,8 +30,9 @@ local getfield = nuts.getfield
local getlist = nuts.getlist
local setlist = nuts.setlist
local removenode = nuts.remove
-local traverse = nuts.traverse
-local traverse_id = nuts.traverse_id
+
+local nextnode = nuts.traversers.node
+local nextwhatsit = nuts.traversers.whatsit
local nodecodes = nodes.nodecodes
local whatsitcodes = nodes.whatsitcodes
@@ -193,7 +194,7 @@ end
-- maybe actions will get parent too
local function delayed(head,parent) -- direct based
- for target in traverse(head) do
+ for target, id in nextnode, head do
local p = propertydata[target]
if p then
-- local deferred = p.deferred -- kind of late lua (but too soon as we have no access to pdf.h/v)
@@ -244,7 +245,6 @@ local function delayed(head,parent) -- direct based
end
-- end
end
- local id = getid(target)
if id == hlist_code or id == vlist_code then
local list = getlist(target)
if list then
@@ -268,14 +268,13 @@ function properties.delayed(head) --
if nofdelayed > 0 then
-- if next(propertydata) then
starttiming(properties)
- head = delayed(tonut(head))
+ head = delayed(head)
stoptiming(properties)
- return tonode(head), true -- done in shipout anyway
-- else
-- delayed = 0
- -- end
+ -- end
end
- return head, false
+ return head
end
-- more explicit ones too
@@ -317,102 +316,203 @@ table.setmetatableindex(anchored,function(t,k)
return v
end)
-function properties.attach(head)
+-- function properties.attach(head)
+--
+-- if nofslots <= 0 then
+-- return head
+-- end
+--
+-- local last = nil
+--
+-- starttiming(properties)
+--
+-- for source in nextwhatsit, head do
+-- if getsubtype(source) == userdefined_code then
+-- if last then
+-- removenode(head,last,true)
+-- last = nil
+-- end
+-- if getfield(source,"user_id") == property_id then
+-- local slot = getfield(source,"value")
+-- local data = cache[slot]
+-- if data then
+-- cache[slot] = nil
+-- local where = data[1]
+-- local target = anchored[where](source)
+-- if target then
+-- local first = data[2]
+-- local method = type(first)
+-- local p_target = propertydata[target]
+-- local p_source = propertydata[source]
+-- if p_target then
+-- if p_source then
+-- for k, v in next, p_source do
+-- p_target[k] = v
+-- end
+-- end
+-- if method == "table" then
+-- for k, v in next, first do
+-- p_target[k] = v
+-- end
+-- elseif method == "function" then
+-- first(target,head,where,p_target,unpack(data,3))
+-- elseif method == "string" then
+-- actions[first](target,head,where,p_target,unpack(data,3))
+-- end
+-- elseif p_source then
+-- if method == "table" then
+-- propertydata[target] = p_source
+-- for k, v in next, first do
+-- p_source[k] = v
+-- end
+-- elseif method == "function" then
+-- propertydata[target] = p_source
+-- first(target,head,where,p_source,unpack(data,3))
+-- elseif method == "string" then
+-- propertydata[target] = p_source
+-- actions[first](target,head,where,p_source,unpack(data,3))
+-- end
+-- else
+-- if method == "table" then
+-- propertydata[target] = first
+-- elseif method == "function" then
+-- local t = { }
+-- propertydata[target] = t
+-- first(target,head,where,t,unpack(data,3))
+-- elseif method == "string" then
+-- local t = { }
+-- propertydata[target] = t
+-- actions[first](target,head,where,t,unpack(data,3))
+-- end
+-- end
+-- if trace_setting then
+-- report_setting("node %i, id %s, data %s",
+-- target,nodecodes[getid(target)],serialize(propertydata[target],false))
+-- end
+-- end
+-- if nofslots == 1 then
+-- nofslots = 0
+-- last = source
+-- break
+-- else
+-- nofslots = nofslots - 1
+-- end
+-- end
+-- last = source
+-- end
+-- end
+-- end
+--
+-- if last then
+-- removenode(head,last,true)
+-- end
+--
+-- stoptiming(properties)
+--
+-- return head
+--
+-- end
- if nofslots <= 0 then
- return head, false
- end
+if LUATEXVERSION >= 1.090 then
+
+ function properties.attach(head)
- local done = false
- local last = nil
- local head = tonut(head)
+ if nofslots <= 0 then
+ return head
+ end
- starttiming(properties)
+ local last = nil
- for source in traverse_id(whatsit_code,head) do
- if getsubtype(source) == userdefined_code then
- if last then
- removenode(head,last,true)
- last = nil
- end
- if getfield(source,"user_id") == property_id then
- local slot = getfield(source,"value")
- local data = cache[slot]
- if data then
- cache[slot] = nil
- local where = data[1]
- local target = anchored[where](source)
- if target then
- local first = data[2]
- local method = type(first)
- local p_target = propertydata[target]
- local p_source = propertydata[source]
- if p_target then
- if p_source then
- for k, v in next, p_source do
- p_target[k] = v
+ starttiming(properties)
+
+ for source, subtype in nextwhatsit, head do
+ if subtype == userdefined_code then
+ if last then
+ removenode(head,last,true)
+ last = nil
+ end
+ if getfield(source,"user_id") == property_id then
+ local slot = getfield(source,"value")
+ local data = cache[slot]
+ if data then
+ cache[slot] = nil
+ local where = data[1]
+ local target = anchored[where](source)
+ if target then
+ local first = data[2]
+ local method = type(first)
+ local p_target = propertydata[target]
+ local p_source = propertydata[source]
+ if p_target then
+ if p_source then
+ for k, v in next, p_source do
+ p_target[k] = v
+ end
end
- end
- if method == "table" then
- for k, v in next, first do
- p_target[k] = v
+ if method == "table" then
+ for k, v in next, first do
+ p_target[k] = v
+ end
+ elseif method == "function" then
+ first(target,head,where,p_target,unpack(data,3))
+ elseif method == "string" then
+ actions[first](target,head,where,p_target,unpack(data,3))
end
- elseif method == "function" then
- first(target,head,where,p_target,unpack(data,3))
- elseif method == "string" then
- actions[first](target,head,where,p_target,unpack(data,3))
- end
- elseif p_source then
- if method == "table" then
- propertydata[target] = p_source
- for k, v in next, first do
- p_source[k] = v
+ elseif p_source then
+ if method == "table" then
+ propertydata[target] = p_source
+ for k, v in next, first do
+ p_source[k] = v
+ end
+ elseif method == "function" then
+ propertydata[target] = p_source
+ first(target,head,where,p_source,unpack(data,3))
+ elseif method == "string" then
+ propertydata[target] = p_source
+ actions[first](target,head,where,p_source,unpack(data,3))
+ end
+ else
+ if method == "table" then
+ propertydata[target] = first
+ elseif method == "function" then
+ local t = { }
+ propertydata[target] = t
+ first(target,head,where,t,unpack(data,3))
+ elseif method == "string" then
+ local t = { }
+ propertydata[target] = t
+ actions[first](target,head,where,t,unpack(data,3))
end
- elseif method == "function" then
- propertydata[target] = p_source
- first(target,head,where,p_source,unpack(data,3))
- elseif method == "string" then
- propertydata[target] = p_source
- actions[first](target,head,where,p_source,unpack(data,3))
end
- else
- if method == "table" then
- propertydata[target] = first
- elseif method == "function" then
- local t = { }
- propertydata[target] = t
- first(target,head,where,t,unpack(data,3))
- elseif method == "string" then
- local t = { }
- propertydata[target] = t
- actions[first](target,head,where,t,unpack(data,3))
+ if trace_setting then
+ report_setting("node %i, id %s, data %s",
+ target,nodecodes[getid(target)],serialize(propertydata[target],false))
end
end
- if trace_setting then
- report_setting("node %i, id %s, data %s",
- target,nodecodes[getid(target)],serialize(propertydata[target],false))
+ if nofslots == 1 then
+ nofslots = 0
+ last = source
+ break
+ else
+ nofslots = nofslots - 1
end
end
- if nofslots == 1 then
- nofslots = 0
- last = source
- break
- else
- nofslots = nofslots - 1
- end
+ last = source
end
- last = source
end
end
- end
- if last then
- removenode(head,last,true)
- end
+ if last then
+ removenode(head,last,true)
+ end
- stoptiming(properties)
+ stoptiming(properties)
- return head, done
+ return head
+
+ end
+
+local tasks = nodes.tasks
end
@@ -420,9 +520,6 @@ local tasks = nodes.tasks
-- maybe better hard coded in-place
--- tasks.prependaction("processors","before","nodes.properties.attach")
--- tasks.appendaction("shipouts","normalizers","nodes.properties.delayed")
-
statistics.register("properties processing time", function()
return statistics.elapsedseconds(properties)
end)
@@ -430,7 +527,7 @@ end)
-- only for development
-- local function show(head,level,report)
--- for target in traverse(head) do
+-- for target in nextnode, head do
-- local p = propertydata[target]
-- if p then
-- report("level %i, node %i, id %s, data %s",