summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/node-pro.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-pro.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/node-pro.lua115
1 files changed, 68 insertions, 47 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-pro.lua b/Master/texmf-dist/tex/context/base/node-pro.lua
index 4f5b3dcbe9c..2d04a4d7185 100644
--- a/Master/texmf-dist/tex/context/base/node-pro.lua
+++ b/Master/texmf-dist/tex/context/base/node-pro.lua
@@ -7,37 +7,41 @@ if not modules then modules = { } end modules ['node-pro'] = {
}
local utf = unicode.utf8
+local utfchar = utf.char
local format, concat = string.format, table.concat
local trace_callbacks = false trackers.register("nodes.callbacks", function(v) trace_callbacks = v end)
-local glyph = node.id('glyph')
+local report_nodes = logs.reporter("nodes","processors")
-local free_node = node.free
-local first_character = node.first_character
+local nodes, node = nodes, node
-nodes.processors = nodes.processors or { }
+local nodecodes = nodes.nodecodes
+local glyph_code = nodecodes.glyph
+local tasks = nodes.tasks
+
+local free_node = node.free
+local first_glyph = node.first_glyph or node.first_character
+
+nodes.processors = nodes.processors or { }
+local processors = nodes.processors
-- vbox: grouptype: vbox vtop output split_off split_keep | box_type: exactly|aditional
-- hbox: grouptype: hbox adjusted_hbox(=hbox_in_vmode) | box_type: exactly|aditional
-lists = lists or { }
-chars = chars or { }
-words = words or { } -- not used yet
-
-local actions = tasks.actions("processors",4)
+local actions = tasks.actions("processors")
local n = 0
-local function reconstruct(head)
- local t = { }
- local h = head
+local function reconstruct(head) -- we probably have a better one
+ local t, n, h = { }, 0, head
while h do
+ n = n + 1
local id = h.id
- if id == glyph then
- t[#t+1] = utf.char(h.char)
+ if id == glyph_code then -- todo: disc etc
+ t[n] = utfchar(h.char)
else
- t[#t+1] = "[]"
+ t[n] = "[]"
end
h = h.next
end
@@ -52,16 +56,18 @@ local function tracer(what,state,head,groupcode,before,after,show)
end
n = n + 1
if show then
- logs.report("nodes","%s %s: %s, group: %s, nodes: %s -> %s, string: %s",what,n,state,groupcode,before,after,reconstruct(head))
+ report_nodes("%s %s: %s, group: %s, nodes: %s -> %s, string: %s",what,n,state,groupcode,before,after,reconstruct(head))
else
- logs.report("nodes","%s %s: %s, group: %s, nodes: %s -> %s",what,n,state,groupcode,before,after)
+ report_nodes("%s %s: %s, group: %s, nodes: %s -> %s",what,n,state,groupcode,before,after)
end
end
-nodes.processors.enabled = true -- thsi will become a proper state (like trackers)
+processors.tracer = tracer
-function nodes.processors.pre_linebreak_filter(head,groupcode,size,packtype,direction)
- local first, found = first_character(head)
+processors.enabled = true -- this will become a proper state (like trackers)
+
+function processors.pre_linebreak_filter(head,groupcode,size,packtype,direction)
+ local first, found = first_glyph(head)
if found then
if trace_callbacks then
local before = nodes.count(head,true)
@@ -84,51 +90,66 @@ function nodes.processors.pre_linebreak_filter(head,groupcode,size,packtype,dire
return true
end
-function nodes.processors.hpack_filter(head,groupcode,size,packtype,direction)
- local first, found = first_character(head)
- if found then
- if trace_callbacks then
- local before = nodes.count(head,true)
- local head, done = actions(head,groupcode,size,packtype,direction)
- local after = nodes.count(head,true)
- if done then
- tracer("hpack","changed",head,groupcode,before,after,true)
+local enabled = true
+
+function processors.hpack_filter(head,groupcode,size,packtype,direction)
+ if enabled then
+ local first, found = first_glyph(head)
+ if found then
+ if trace_callbacks then
+ local before = nodes.count(head,true)
+ local head, done = actions(head,groupcode,size,packtype,direction)
+ local after = nodes.count(head,true)
+ if done then
+ tracer("hpack","changed",head,groupcode,before,after,true)
+ else
+ tracer("hpack","unchanged",head,groupcode,before,after,true)
+ end
+ return (done and head) or true
else
- tracer("hpack","unchanged",head,groupcode,before,after,true)
+ local head, done = actions(head,groupcode,size,packtype,direction)
+ return (done and head) or true
end
- return (done and head) or true
- else
- local head, done = actions(head,groupcode,size,packtype,direction)
- return (done and head) or true
+ elseif trace_callbacks then
+ local n = nodes.count(head,false)
+ tracer("hpack","no chars",head,groupcode,n,n)
end
- elseif trace_callbacks then
- local n = nodes.count(head,false)
- tracer("hpack","no chars",head,groupcode,n,n)
end
return true
end
-callbacks.register('pre_linebreak_filter', nodes.processors.pre_linebreak_filter,"all kind of horizontal manipulations (before par break)")
-callbacks.register('hpack_filter' , nodes.processors.hpack_filter,"all kind of horizontal manipulations")
+local hpack = node.hpack
+
+function nodes.fasthpack(...) -- todo: pass explicit arguments
+ enabled = false
+ local hp, b = hpack(...)
+ enabled = true
+ return hp, b
+end
-local actions = tasks.actions("finalizers",1) -- head, where
+callbacks.register('pre_linebreak_filter', processors.pre_linebreak_filter,"all kind of horizontal manipulations (before par break)")
+callbacks.register('hpack_filter' , processors.hpack_filter,"all kind of horizontal manipulations")
--- beware, these are packaged boxes so no first_character test
+local actions = tasks.actions("finalizers") -- head, where
+
+-- beware, these are packaged boxes so no first_glyph test
-- maybe some day a hash with valid groupcodes
--
-- beware, much can pass twice, for instance vadjust passes two times
+--
+-- something weird here .. group mvl when making a vbox
-function nodes.processors.post_linebreak_filter(head,groupcode)
---~ local first, found = first_character(head)
+function processors.post_linebreak_filter(head,groupcode)
+--~ local first, found = first_glyph(head)
--~ if found then
if trace_callbacks then
local before = nodes.count(head,true)
local head, done = actions(head,groupcode)
local after = nodes.count(head,true)
if done then
- tracer("finalizer","changed",head,groupcode,before,after,true)
+ tracer("post_linebreak","changed",head,groupcode,before,after,true)
else
- tracer("finalizer","unchanged",head,groupcode,before,after,true)
+ tracer("post_linebreak","unchanged",head,groupcode,before,after,true)
end
return (done and head) or true
else
@@ -137,12 +158,12 @@ function nodes.processors.post_linebreak_filter(head,groupcode)
end
--~ elseif trace_callbacks then
--~ local n = nodes.count(head,false)
---~ tracer("finalizer","no chars",head,groupcode,n,n)
+--~ tracer("post_linebreak","no chars",head,groupcode,n,n)
--~ end
--~ return true
end
-callbacks.register('post_linebreak_filter', nodes.processors.post_linebreak_filter,"all kind of horizontal manipulations (after par break)")
+callbacks.register('post_linebreak_filter', processors.post_linebreak_filter,"all kind of horizontal manipulations (after par break)")
statistics.register("h-node processing time", function()
return statistics.elapsedseconds(nodes,"including kernel") -- hm, ok here?