summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/base/ltluatex.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-02-21 23:29:27 +0000
committerKarl Berry <karl@freefriends.org>2017-02-21 23:29:27 +0000
commit516a8bbf9db95a88ce2fdd2cf3407216f67e8049 (patch)
tree8a6508ac24539e2003f1efd5c758cdcea9e6891b /Master/texmf-dist/source/latex/base/ltluatex.dtx
parent7714e343948bfc6ff5fd5c4b7297c229f37070fa (diff)
latex (21feb17)
git-svn-id: svn://tug.org/texlive/trunk@43287 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/base/ltluatex.dtx')
-rw-r--r--Master/texmf-dist/source/latex/base/ltluatex.dtx61
1 files changed, 40 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/latex/base/ltluatex.dtx b/Master/texmf-dist/source/latex/base/ltluatex.dtx
index e5f507258f3..ffde612ec4b 100644
--- a/Master/texmf-dist/source/latex/base/ltluatex.dtx
+++ b/Master/texmf-dist/source/latex/base/ltluatex.dtx
@@ -24,7 +24,7 @@
\ProvidesFile{ltluatex.dtx}
%</driver>
%<*tex>
-[2017/01/20 v1.1b
+[2017/02/18 v1.1c
%</tex>
%<plain> LuaTeX support for plain TeX (core)
%<*tex>
@@ -200,6 +200,17 @@
% The number is returned and also \meta{name} argument is added to the
% |lua.name| array at that index.
%
+% These functions all require access to a named \TeX{} count register
+% to manage their allocations. The standard names are those defined
+% above for access from \TeX{}, \emph{e.g.}~\string\e@alloc@attribute@count,
+% but these can be adjusted by defining the variable
+% \texttt{\meta{type}\_count\_name} before loading |ltluatex.lua|, for example
+% \begin{verbatim}
+% local attribute_count_name = "attributetracker"
+% require("ltluatex")
+% \end{verbatim}
+% would use a \TeX{} |\count| (|\countdef|'d token) called |attributetracker|
+% in place of \string\e@alloc@attribute@count.
%
% \subsection{Lua access to \TeX{} register numbers}
%
@@ -1080,6 +1091,7 @@ luatexbase.registernumber = registernumber
%
% \begin{macro}{new\_attribute}
% \changes{v1.0a}{2015/09/24}{Function added}
+% \changes{v1.1c}{2017/02/18}{Parameterise count used in tracking}
% As attributes are used for Lua manipulations its useful to be able
% to assign from this end.
% \begin{macrocode}
@@ -1090,20 +1102,21 @@ __index = function(t,key)
return registernumber(key) or nil
end}
)
-luatexbase.attributes=attributes
+luatexbase.attributes = attributes
% \end{macrocode}
%
% \begin{macrocode}
+local attribute_count_name = attribute_count_name or "e@alloc@attribute@count"
local function new_attribute(name)
- tex_setcount("global", "e@alloc@attribute@count",
- tex_count["e@alloc@attribute@count"] + 1)
- if tex_count["e@alloc@attribute@count"] > 65534 then
+ tex_setcount("global", attribute_count_name,
+ tex_count[attribute_count_name] + 1)
+ if tex_count[attribute_count_name] > 65534 then
luatexbase_error("No room for a new \\attribute")
end
- attributes[name]= tex_count["e@alloc@attribute@count"]
+ attributes[name]= tex_count[attribute_count_name]
luatexbase_log("Lua-only attribute " .. name .. " = " ..
- tex_count["e@alloc@attribute@count"])
- return tex_count["e@alloc@attribute@count"]
+ tex_count[attribute_count_name])
+ return tex_count[attribute_count_name]
end
luatexbase.new_attribute = new_attribute
% \end{macrocode}
@@ -1112,17 +1125,19 @@ luatexbase.new_attribute = new_attribute
% \subsection{Custom whatsit allocation}
%
% \begin{macro}{new\_whatsit}
+% \changes{v1.1c}{2017/02/18}{Parameterise count used in tracking}
% Much the same as for attribute allocation in Lua.
% \begin{macrocode}
+local whatsit_count_name = whatsit_count_name or "e@alloc@whatsit@count"
local function new_whatsit(name)
- tex_setcount("global", "e@alloc@whatsit@count",
- tex_count["e@alloc@whatsit@count"] + 1)
- if tex_count["e@alloc@whatsit@count"] > 65534 then
+ tex_setcount("global", whatsit_count_name,
+ tex_count[whatsit_count_name] + 1)
+ if tex_count[whatsit_count_name] > 65534 then
luatexbase_error("No room for a new custom whatsit")
end
luatexbase_log("Custom whatsit " .. (name or "") .. " = " ..
- tex_count["e@alloc@whatsit@count"])
- return tex_count["e@alloc@whatsit@count"]
+ tex_count[whatsit_count_name])
+ return tex_count[whatsit_count_name]
end
luatexbase.new_whatsit = new_whatsit
% \end{macrocode}
@@ -1131,18 +1146,20 @@ luatexbase.new_whatsit = new_whatsit
% \subsection{Bytecode register allocation}
%
% \begin{macro}{new\_bytecode}
+% \changes{v1.1c}{2017/02/18}{Parameterise count used in tracking}
% Much the same as for attribute allocation in Lua.
% The optional \meta{name} argument is used in the log if given.
% \begin{macrocode}
+local bytecode_count_name = bytecode_count_name or "e@alloc@bytecode@count"
local function new_bytecode(name)
- tex_setcount("global", "e@alloc@bytecode@count",
- tex_count["e@alloc@bytecode@count"] + 1)
- if tex_count["e@alloc@bytecode@count"] > 65534 then
+ tex_setcount("global", bytecode_count_name,
+ tex_count[bytecode_count_name] + 1)
+ if tex_count[bytecode_count_name] > 65534 then
luatexbase_error("No room for a new bytecode register")
end
luatexbase_log("Lua bytecode " .. (name or "") .. " = " ..
- tex_count["e@alloc@bytecode@count"])
- return tex_count["e@alloc@bytecode@count"]
+ tex_count[bytecode_count_name])
+ return tex_count[bytecode_count_name]
end
luatexbase.new_bytecode = new_bytecode
% \end{macrocode}
@@ -1151,13 +1168,15 @@ luatexbase.new_bytecode = new_bytecode
% \subsection{Lua chunk name allocation}
%
% \begin{macro}{new\_chunkname}
+% \changes{v1.1c}{2017/02/18}{Parameterise count used in tracking}
% As for bytecode registers but also store the name in the
% |lua.name| table.
% \begin{macrocode}
+local chunkname_count_name = chunkname_count_name or "e@alloc@luachunk@count"
local function new_chunkname(name)
- tex_setcount("global", "e@alloc@luachunk@count",
- tex_count["e@alloc@luachunk@count"] + 1)
- local chunkname_count = tex_count["e@alloc@luachunk@count"]
+ tex_setcount("global", chunkname_count_name,
+ tex_count[chunkname_count_name] + 1)
+ local chunkname_count = tex_count[chunkname_count_name]
chunkname_count = chunkname_count + 1
if chunkname_count > 65534 then
luatexbase_error("No room for a new chunkname")