lpdf-nod.lua /size: 3469 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
lpdf-nod
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to lpdf-ini.mkiv
"
,
4
author
=
"
Hans Hagen, PRAGMA-ADE, Hasselt NL
"
,
5
copyright
=
"
PRAGMA ADE / ConTeXt Development Team
"
,
6
license
=
"
see context related readme files
"
7
}
8 9
local
nodecodes
=
nodes
.
nodecodes
10
local
whatsitcodes
=
nodes
.
whatsitcodes
11 12
local
nodeinjections
=
backends
.
nodeinjections
13 14
local
nuts
=
nodes
.
nuts
15 16
local
setfield
=
nuts
.
setfield
17
local
setdata
=
nuts
.
setdata
18 19
local
copy_node
=
nuts
.
copy
20
local
new_node
=
nuts
.
new
21 22
local
nodepool
=
nuts
.
pool
23
local
register
=
nodepool
.
register
24 25
local
whatsit_code
=
nodecodes
.
whatsit
26 27
local
savewhatsit_code
=
whatsitcodes
.
save
28
local
restorewhatsit_code
=
whatsitcodes
.
restore
29
local
setmatrixwhatsit_code
=
whatsitcodes
.
setmatrix
30
local
literalwhatsit_code
=
whatsitcodes
.
literal
31 32
local
literalvalues
=
nodes
.
literalvalues
33
local
originliteral_code
=
literalvalues
.
origin
34
local
pageliteral_code
=
literalvalues
.
page
35
local
directliteral_code
=
literalvalues
.
direct
36
local
rawliteral_code
=
literalvalues
.
raw
37 38
local
tomatrix
=
drivers
.
helpers
.
tomatrix
39 40
local
originliteralnode
=
register
(
new_node
(
whatsit_code
,
literalwhatsit_code
)
)
setfield
(
originliteralnode
,
"
mode
"
,
originliteral_code
)
41
local
pageliteralnode
=
register
(
new_node
(
whatsit_code
,
literalwhatsit_code
)
)
setfield
(
pageliteralnode
,
"
mode
"
,
pageliteral_code
)
42
local
directliteralnode
=
register
(
new_node
(
whatsit_code
,
literalwhatsit_code
)
)
setfield
(
directliteralnode
,
"
mode
"
,
directliteral_code
)
43
local
rawliteralnode
=
register
(
new_node
(
whatsit_code
,
literalwhatsit_code
)
)
setfield
(
rawliteralnode
,
"
mode
"
,
rawliteral_code
)
44 45
function
nodepool
.
originliteral
(
str
)
local
t
=
copy_node
(
originliteralnode
)
setdata
(
t
,
str
)
return
t
end
46
function
nodepool
.
pageliteral
(
str
)
local
t
=
copy_node
(
pageliteralnode
)
setdata
(
t
,
str
)
return
t
end
47
function
nodepool
.
directliteral
(
str
)
local
t
=
copy_node
(
directliteralnode
)
setdata
(
t
,
str
)
return
t
end
48
function
nodepool
.
rawliteral
(
str
)
local
t
=
copy_node
(
rawliteralnode
)
setdata
(
t
,
str
)
return
t
end
49 50
local
literals
=
{
51
[
originliteral_code
]
=
originliteralnode
,
[
literalvalues
[
originliteral_code
]
]
=
originliteralnode
,
52
[
pageliteral_code
]
=
pageliteralnode
,
[
literalvalues
[
pageliteral_code
]
]
=
pageliteralnode
,
53
[
directliteral_code
]
=
directliteralnode
,
[
literalvalues
[
directliteral_code
]
]
=
directliteralnode
,
54
[
rawliteral_code
]
=
rawliteralnode
,
[
literalvalues
[
rawliteral_code
]
]
=
rawliteralnode
,
55
}
56 57
function
nodepool
.
literal
(
mode
,
str
)
58
if
str
then
59
local
t
=
copy_node
(
literals
[
mode
]
or
pageliteralnode
)
60
setdata
(
t
,
str
)
61
return
t
62
else
63
local
t
=
copy_node
(
pageliteralnode
)
64
setdata
(
t
,
mode
)
65
return
t
66
end
67
end
68 69
local
savenode
=
register
(
new_node
(
whatsit_code
,
savewhatsit_code
)
)
70
local
restorenode
=
register
(
new_node
(
whatsit_code
,
restorewhatsit_code
)
)
71
local
setmatrixnode
=
register
(
new_node
(
whatsit_code
,
setmatrixwhatsit_code
)
)
72 73
function
nodepool
.
save
(
)
74
return
copy_node
(
savenode
)
75
end
76 77
function
nodepool
.
restore
(
)
78
return
copy_node
(
restorenode
)
79
end
80 81
function
nodepool
.
setmatrix
(
rx
,
sx
,
sy
,
ry
,
tx
,
ty
)
82
local
t
=
copy_node
(
setmatrixnode
)
83
setdata
(
t
,
tomatrix
(
rx
,
sx
,
sy
,
ry
,
tx
,
ty
)
)
84
return
t
85
end
86