[latex3-commits] [latex2e-public] r1380 - Parameterise count names used from "Lua side"

noreply at latex-project.org noreply at latex-project.org
Sat Feb 18 19:04:58 CET 2017


Author: joseph
Date: 2017-02-18 19:04:58 +0100 (Sat, 18 Feb 2017)
New Revision: 1380

Modified:
   trunk/base/ltluatex.dtx
Log:
Parameterise count names used from "Lua side"

This allows them to be something other than \e at alloc@..., which is
handy for expl3.


Modified: trunk/base/ltluatex.dtx
===================================================================
--- trunk/base/ltluatex.dtx	2017-02-16 20:32:00 UTC (rev 1379)
+++ trunk/base/ltluatex.dtx	2017-02-18 18:04:58 UTC (rev 1380)
@@ -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 at alloc@attribute at 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 at alloc@attribute at count.
 %
 % \subsection{Lua access to \TeX{} register numbers}
 %
@@ -1080,6 +1091,7 @@
 %
 % \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 @@
 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 at alloc@attribute at count"
 local function new_attribute(name)
-  tex_setcount("global", "e at alloc@attribute at count",
-                          tex_count["e at alloc@attribute at count"] + 1)
-  if tex_count["e at alloc@attribute at 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 at alloc@attribute at count"]
+  attributes[name]= tex_count[attribute_count_name]
   luatexbase_log("Lua-only attribute " .. name .. " = " ..
-                 tex_count["e at alloc@attribute at count"])
-  return tex_count["e at alloc@attribute at count"]
+                 tex_count[attribute_count_name])
+  return tex_count[attribute_count_name]
 end
 luatexbase.new_attribute = new_attribute
 %    \end{macrocode}
@@ -1112,17 +1125,19 @@
 % \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 at alloc@whatsit at count"
 local function new_whatsit(name)
-  tex_setcount("global", "e at alloc@whatsit at count", 
-                         tex_count["e at alloc@whatsit at count"] + 1)
-  if tex_count["e at alloc@whatsit at 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 at alloc@whatsit at count"])
-  return tex_count["e at alloc@whatsit at count"]
+                 tex_count[whatsit_count_name])
+  return tex_count[whatsit_count_name]
 end
 luatexbase.new_whatsit = new_whatsit
 %    \end{macrocode}
@@ -1131,18 +1146,20 @@
 % \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 at alloc@bytecode at count"
 local function new_bytecode(name)
-  tex_setcount("global", "e at alloc@bytecode at count", 
-                         tex_count["e at alloc@bytecode at count"] + 1)
-  if tex_count["e at alloc@bytecode at 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 at alloc@bytecode at count"])
-  return tex_count["e at alloc@bytecode at count"]
+                 tex_count[bytecode_count_name])
+  return tex_count[bytecode_count_name]
 end
 luatexbase.new_bytecode = new_bytecode
 %    \end{macrocode}
@@ -1151,13 +1168,15 @@
 % \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 at alloc@luachunk at count"
 local function new_chunkname(name)
-  tex_setcount("global", "e at alloc@luachunk at count", 
-                         tex_count["e at alloc@luachunk at count"] + 1)
-  local chunkname_count = tex_count["e at alloc@luachunk at 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")



More information about the latex3-commits mailing list