1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
if not modules then modules = { } end modules ['node-ini'] = {
version = 1.001,
comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
--[[ldx--
<p>Most of the code that had accumulated here is now separated in modules.</p>
--ldx]]--
local next, type, tostring = next, type, tostring
local gsub = string.gsub
local concat, remove = table.concat, table.remove
local sortedhash, sortedkeys, swapped = table.sortedhash, table.sortedkeys, table.swapped
--[[ldx--
<p>Access to nodes is what gives <l n='luatex'/> its power. Here we implement a
few helper functions. These functions are rather optimized.</p>
--ldx]]--
nodes = nodes or { }
local nodes = nodes
nodes.handlers = nodes.handlers or { }
local mark = utilities.storage.mark
local allocate = utilities.storage.allocate
local formatcolumns = utilities.formatters.formatcolumns
local getsubtypes = node.subtypes
local getvalues = node.values
tex.magicconstants = { -- we use tex.constants for something else
running = -1073741824, -- null_flag
maxdimen = 1073741823, -- max_dimen
trueinch = 4736286,
}
local listcodes = mark(getsubtypes("list"))
local rulecodes = mark(getsubtypes("rule"))
local dircodes = mark(getsubtypes("dir"))
local glyphcodes = mark(getsubtypes("glyph"))
local disccodes = mark(getsubtypes("disc"))
local gluecodes = mark(getsubtypes("glue"))
local boundarycodes = mark(getsubtypes("boundary"))
local penaltycodes = mark(getsubtypes("penalty"))
local kerncodes = mark(getsubtypes("kern"))
local mathcodes = mark(getsubtypes("math"))
local noadcodes = mark(getsubtypes("noad"))
local radicalcodes = mark(getsubtypes("radical"))
local accentcodes = mark(getsubtypes("accent"))
local fencecodes = mark(getsubtypes("fence"))
----- fractioncodes = mark(getsubtypes("fraction"))
local parcodes = mark(getsubtypes("par"))
local fillvalues = mark(getvalues("fill"))
local dirvalues = mark(getvalues("dir"))
local mathvalues = mark(getvalues("math"))
local function simplified(t)
local r = { }
for k, v in next, t do
r[k] = gsub(v,"_","")
end
return r
end
local noadoptions = allocate {
set = 0x08,
unused_1 = 0x00 + 0x08,
unused_2 = 0x01 + 0x08,
axis = 0x02 + 0x08,
no_axis = 0x04 + 0x08,
exact = 0x10 + 0x08,
left = 0x11 + 0x08,
middle = 0x12 + 0x08,
right = 0x14 + 0x08,
}
local nodecodes = simplified(node.types())
gluecodes = allocate(swapped(gluecodes,gluecodes))
dircodes = allocate(swapped(dircodes,dircodes))
boundarycodes = allocate(swapped(boundarycodes,boundarycodes))
noadcodes = allocate(swapped(noadcodes,noadcodes))
radicalcodes = allocate(swapped(radicalcodes,radicalcodes))
nodecodes = allocate(swapped(nodecodes,nodecodes))
listcodes = allocate(swapped(listcodes,listcodes))
glyphcodes = allocate(swapped(glyphcodes,glyphcodes))
kerncodes = allocate(swapped(kerncodes,kerncodes))
penaltycodes = allocate(swapped(penaltycodes,penaltycodes))
mathcodes = allocate(swapped(mathcodes,mathcodes))
disccodes = allocate(swapped(disccodes,disccodes))
accentcodes = allocate(swapped(accentcodes,accentcodes))
fencecodes = allocate(swapped(fencecodes,fencecodes))
parcodes = allocate(swapped(parcodes,parcodes))
rulecodes = allocate(swapped(rulecodes,rulecodes))
noadoptions = allocate(swapped(noadoptions,noadoptions))
dirvalues = allocate(swapped(dirvalues,dirvalues))
fillvalues = allocate(swapped(fillvalues,fillvalues))
mathvalues = allocate(swapped(mathvalues,mathvalues))
nodes.gluecodes = gluecodes
nodes.dircodes = dircodes
nodes.boundarycodes = boundarycodes
nodes.noadcodes = noadcodes
nodes.listcodes = listcodes
nodes.glyphcodes = glyphcodes
nodes.kerncodes = kerncodes
nodes.penaltycodes = penaltycodes
nodes.mathcodes = mathcodes
nodes.disccodes = disccodes
nodes.accentcodes = accentcodes
nodes.radicalcodes = radicalcodes
nodes.fencecodes = fencecodes
nodes.parcodes = parcodes
nodes.rulecodes = rulecodes
nodes.noadoptions = noadoptions
nodes.fillvalues = fillvalues
nodes.fillcodes = fillvalues -- for now
nodes.dirvalues = dirvalues
nodes.mathvalues = mathvalues
nodes.nodecodes = nodecodes
local subtypes = allocate {
glue = gluecodes,
dir = dircodes,
boundary = boundarycodes,
noad = noadcodes,
glyph = glyphcodes,
kern = kerncodes,
penalty = penaltycodes,
math = mathcodes,
disc = disccodes,
accent = accentcodes,
radical = radicalcodes,
fence = fencecodes,
par = parcodes,
rule = rulecodes,
vlist = listcodes,
hlist = listcodes,
-- list = listcodes,
-- parameter = parametercodes,
-- user = usercodes,
}
for k, v in table.sortedhash(subtypes) do
local i = nodecodes[k]
if i and not subtypes[i] then
subtypes[i] = v
end
end
nodes.subtypes = subtypes
-- a few more friendly aliases:
nodes.skipcodes = gluecodes
nodes.directioncodes = dircodes
nodes.discretionarycodes = disccodes
nodes.directionvalues = dirvalues
glyphcodes.glyph = glyphcodes.character
gluecodes.parfillrightskip = gluecodes.parfillrightskip or gluecodes.parfillskip
gluecodes.parfillskip = gluecodes.parfillskip or gluecodes.parfillrightskip
listcodes.row = listcodes.alignment
listcodes.column = listcodes.alignment
kerncodes.kerning = kerncodes.fontkern
kerncodes.italiccorrection = kerncodes.italiccorrection or 1 -- new
nodes.noadoptions = {
set = 0x08,
unused_1 = 0x00 + 0x08,
unused_2 = 0x01 + 0x08,
axis = 0x02 + 0x08,
no_axis = 0x04 + 0x08,
exact = 0x10 + 0x08,
left = 0x11 + 0x08,
middle = 0x12 + 0x08,
right = 0x14 + 0x08,
}
-- We use the real node code numbers.
local texsetintegervalue = tex.setintegervalue
for i=0,nodecodes.glyph do
texsetintegervalue(nodecodes[i] .. "nodecode",i,"immutable")
end
for i=0,#gluecodes do
texsetintegervalue(gluecodes[i] .. "subtypecode",i,"immutable")
end
nodes.specialskipcodes = {
[gluecodes.leftskip] = true,
[gluecodes.rightskip] = true,
[gluecodes.lefthangskip] = true,
[gluecodes.righthangskip] = true,
[gluecodes.parfillleftskip or parfillskip_code] = true,
[gluecodes.parfillrightskip or parfillskip_code] = true,
[gluecodes.indentskip] = true,
[gluecodes.correctionskip] = true,
}
|