[Dev-luatex] getnext et al.

Philipp Gesang philipp.gesang at alumni.uni-heidelberg.de
Tue May 6 07:39:30 CEST 2014

Hi Patrick!

···<Datum: Saturday, 03. May 2014>···<Von: Patrick Gundlach>···

> Hi,
> reading the chapter 8.2 in the manual, I wonder how to call getnext and its ilk. Is this used like node.getnext()?

Yes, but they operate on integer references which you obtain by
calling node.direct.todirect() on the node you start out with:

    local direct            = node.direct
    local getnext           = direct.getnext
    local todirect          = direct.todirect
    local getid             = direct.getid
    local getfield          = direct.getfield
    local setfield          = direct.setfield
    local glyph_node        = node.id "glyph"
    local asciiA, asciia    = string.byte "A", string.byte "a"
    local r13 = function (chr)
      local d
      d = chr - asciiA if 0 <= d and d <= 25 then return (d + 13) % 26 + asciiA end
      d = chr - asciia if 0 <= d and d <= 25 then return (d + 13) % 26 + asciia end
      return chr
    local filter = function (hd)
      local cur = todirect (hd)                     ---> node -> int
      while cur do
        if getid (cur) == glyph_node then           ---> if cur.id == glyph_node
          local chr = getfield (cur, "char")        ---> chr = cur.char
          setfield (cur, "char", r13 (chr))         ---> cur.char = r13 (cur.char)
        cur = getnext (cur)                         ---> cur = cur.next
      return hd                                     ---> return first node
    callback.register ("pre_linebreak_filter", filter)

To my knowledge, the correspondence between the functions under
node.* and node.direct.* is most obvious in node-nut.lua:


@Hans: Considering that node.direct has been part of the master
branch for some time and the new model is used in Context without
users reporting segfaults, could you give an ETA on when the
generic fontloader will benefit from it?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://www.ntg.nl/pipermail/dev-luatex/attachments/20140506/be7213ae/attachment.pgp>

More information about the dev-luatex mailing list