[latex3-commits] [git/LaTeX3-latex3-latex2e] master: Add luatexbase.new_luafunction() (33f1480)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Oct 21 22:35:47 CEST 2018
Repository : https://github.com/latex3/latex2e
On branch : master
Link : https://github.com/latex3/latex2e/commit/33f14809ba212e30fadf5d013e9b575c8ce99222
>---------------------------------------------------------------
commit 33f14809ba212e30fadf5d013e9b575c8ce99222
Author: Marcel Krüger <zauguin at gmail.com>
Date: Thu Oct 11 11:11:58 2018 +0200
Add luatexbase.new_luafunction()
>---------------------------------------------------------------
33f14809ba212e30fadf5d013e9b575c8ce99222
base/ltluatex.dtx | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/base/ltluatex.dtx b/base/ltluatex.dtx
index 7c09f5c..5645d3a 100644
--- a/base/ltluatex.dtx
+++ b/base/ltluatex.dtx
@@ -24,7 +24,7 @@
\ProvidesFile{ltluatex.dtx}
%</driver>
%<*tex>
-[2018/08/18 v1.1h
+[2018/10/21 v1.1i
%</tex>
%<plain> LuaTeX support for plain TeX (core)
%<*tex>
@@ -200,6 +200,14 @@
% The number is returned and also \meta{name} argument is added to the
% |lua.name| array at that index.
%
+% \noindent
+% \DescribeMacro{new_luafunction}
+% |luatexbase.new_luafunction(|\meta{functionname}|)|\\
+% Returns an allocation number for a lua function for use
+% with |\luafunction|, |\lateluafunction|, and |\luadef|,
+% indexed from~$1$. The optional \meta{functionname} argument
+% is just used for logging.
+%
% 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,
@@ -1184,6 +1192,29 @@ luatexbase.new_chunkname = new_chunkname
% \end{macrocode}
% \end{macro}
%
+% \subsection{Lua function allocation}
+%
+% \begin{macro}{new_luafunction}
+% \changes{v1.1i}{2018/10/21}{Function added}
+% Much the same as for attribute allocation in Lua.
+% The optional \meta{name} argument is used in the log if given.
+% \begin{macrocode}
+local luafunction_count_name =
+ luafunction_count_name or "e at alloc@luafunction at count"
+local function new_luafunction(name)
+ tex_setcount("global", luafunction_count_name,
+ tex_count[luafunction_count_name] + 1)
+ if tex_count[luafunction_count_name] > 65534 then
+ luatexbase_error("No room for a new luafunction register")
+ end
+ luatexbase_log("Lua function " .. (name or "") .. " = " ..
+ tex_count[luafunction_count_name])
+ return tex_count[luafunction_count_name]
+end
+luatexbase.new_luafunction = new_luafunction
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{Lua callback management}
%
% The native mechanism for callbacks in Lua\TeX\ allows only one per function.
More information about the latex3-commits
mailing list