[latex3-commits] [git/LaTeX3-latex3-latex3] luaintarray: Fix and use luadata mechanism (6ddcb8627)
Marcel Fabian Krüger
tex at 2krueger.de
Tue Aug 11 00:47:47 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : luaintarray
Link : https://github.com/latex3/latex3/commit/6ddcb8627a16b2afcb807b8621a962b3e00234e2
>---------------------------------------------------------------
commit 6ddcb8627a16b2afcb807b8621a962b3e00234e2
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Tue Aug 11 00:47:47 2020 +0200
Fix and use luadata mechanism
>---------------------------------------------------------------
6ddcb8627a16b2afcb807b8621a962b3e00234e2
l3kernel/l3bootstrap.dtx | 1 +
l3kernel/l3intarray.dtx | 27 +++++++++++++++++++++------
l3kernel/l3luatex.dtx | 11 ++++++-----
3 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/l3kernel/l3bootstrap.dtx b/l3kernel/l3bootstrap.dtx
index cf749116d..fa7998787 100644
--- a/l3kernel/l3bootstrap.dtx
+++ b/l3kernel/l3bootstrap.dtx
@@ -186,6 +186,7 @@
\expandafter\ifx\csname newcatcodetable\endcsname\relax
\input{ltluatex}%
\fi
+ \newluabytecode\expl at luadata@bytecode
\directlua{require("expl3")}%
% \end{macrocode}
% As the user might be making a custom format, no assumption is made about
diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index c39b79bdc..8b1b64911 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -259,17 +259,16 @@ if token.set_lua and luatexbase and luatexbase.new_luafunction then
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\intarray_count:N, \intarray_count:c}
-% \begin{macro}[EXP]{\@@_gset_count:Nw}
-% Set and get the size of an array. ``Setting the size'' means in this context that
-% we add zeros until we reach the desired size.
+% \begin{macro}{@@_table}
+% Internal helper to scan an intarray token, extract the associated
+% Lua table and return an error if the input is invalid.
% \begin{macrocode}
%<*lua>
local undefined_cs = token.command_id'undefined_cs'
local functions = lua.get_functions_table()
local @@_table do
- local tables = {[0] = {}}
+ local tables = get_luadata and get_luadata'@@' or {[0] = {}}
function @@_table()
local t = token.scan_token()
if t.csname ~= 's_@@' then
@@ -284,8 +283,24 @@ local @@_table do
tables[i] = table
return table
end
+ if register_luadata then
+ register_luadata('@@', function()
+ local t = "{[0]={},"
+ for i=1, #tables do
+ t = string.format("%s{%s},", t, table.concat(tables[i], ','))
+ end
+ return t .. "}"
+ end)
+ end
end
-
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\intarray_count:N, \intarray_count:c}
+% \begin{macro}[EXP]{\@@_gset_count:Nw}
+% Set and get the size of an array. ``Setting the size'' means in this context that
+% we add zeros until we reach the desired size.
+% \begin{macrocode}
local @@_gset_count_func do
local tok = token.create'@@_gset_count:Nw'
if tok.command == undefined_cs then
diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index f513a60c7..6227b8834 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -574,8 +574,8 @@ l3kernel.shellescape = shellescape
local register_luadata, get_luadata
if luatexbase then
- local register = token.create'luadata_bytecode_register'.index
- if status.initex then
+ local register = token.create'expl at luadata@bytecode'.index
+ if status.ini_version then
% \end{macrocode}
%
% \begin{macro}{register_luadata}
@@ -600,14 +600,14 @@ if luatexbase then
% The actual work is done in \texttt{pre_dump}. The \texttt{luadata_order} is used
% to ensure that the order is consistent over multiple runs.
% \begin{macrocode}
- luatexbase.add_to_callback("pre_dump", function()
+luatexbase.add_to_callback("pre_dump", function()
if next(luadata) then
local str = "return {"
for i=1, #luadata_order do
local name = luadata_order[i]
- str = string.format('%s["%q"]=%s,', str, name, luadata[name]())
+ str = string.format('%s[%q]=%s,', str, name, luadata[name]())
end
- lua.bytecode[register] = load(str .. "}")
+ lua.bytecode[register] = assert(load(str .. "}"))
end
end, "latex3.luadata")
else
@@ -620,6 +620,7 @@ if luatexbase then
% \begin{macrocode}
local luadata = lua.bytecode[register]
if luadata then
+ lua.bytecode[register] = nil
luadata = luadata()
end
function get_luadata(name)
More information about the latex3-commits
mailing list.