2019-07-17 21:14:34 +02:00
|
|
|
\begingroup
|
|
|
|
\catcode`\^^^^ffff=11
|
|
|
|
\catcode`\@=11
|
|
|
|
\toks0{%
|
2019-07-18 13:10:33 +02:00
|
|
|
do
|
|
|
|
local function frozen(s)
|
|
|
|
local t = token.create(s)
|
|
|
|
return token.new(t.mode, t.command)
|
|
|
|
end
|
2019-07-17 21:14:34 +02:00
|
|
|
local dimen_cmd = token.command_id'assign_dimen'
|
2019-07-25 13:17:38 +02:00
|
|
|
local count_cmd = token.command_id'assign_int'
|
2019-07-17 21:14:34 +02:00
|
|
|
local tex_params = {}
|
|
|
|
local texmeta = getmetatable(tex)
|
|
|
|
local texmetaoldindex = texmeta.__index
|
|
|
|
local texmetaoldnewindex = texmeta.__newindex
|
|
|
|
function texmeta.__index(t, k)
|
|
|
|
local v = tex_params[k]
|
|
|
|
if v then
|
2019-07-25 13:17:38 +02:00
|
|
|
if v.command == count_cmd then
|
|
|
|
return tex.count[v.index]
|
|
|
|
elseif v.command == dimen_cmd then
|
2019-07-17 21:14:34 +02:00
|
|
|
return tex.dimen[v.index]
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return texmetaoldindex(t, k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function texmeta.__newindex(t, k, v)
|
|
|
|
local p = tex_params[k]
|
|
|
|
if p then
|
2019-07-25 13:17:38 +02:00
|
|
|
if p.command == count_cmd then
|
|
|
|
tex.count[p.index] = v
|
|
|
|
elseif p.command == dimen_cmd then
|
2019-07-17 21:14:34 +02:00
|
|
|
tex.dimen[p.index] = v
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return texmetaoldnewindex(t, k, v)
|
|
|
|
end
|
|
|
|
end
|
2019-07-18 13:10:33 +02:00
|
|
|
local pdf_params = {}
|
|
|
|
pdf.variable_tokens = pdf_params
|
|
|
|
pdf.variable = setmetatable({}, {
|
|
|
|
__index = function(t, k)
|
|
|
|
local v = pdf_params[k]
|
|
|
|
if v then
|
2019-07-25 13:17:38 +02:00
|
|
|
if v.command == count_cmd then
|
|
|
|
return tex.count[v.index]
|
|
|
|
elseif v.command == dimen_cmd then
|
2019-07-18 13:10:33 +02:00
|
|
|
return tex.dimen[v.index]
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return texmetaoldindex(t, k)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
__newindex = function(t, k, v)
|
|
|
|
local p = pdf_params[k]
|
|
|
|
if p then
|
2019-07-25 13:17:38 +02:00
|
|
|
if p.command == count_cmd then
|
|
|
|
tex.count[p.index] = v
|
|
|
|
elseif p.command == dimen_cmd then
|
2019-07-18 13:10:33 +02:00
|
|
|
tex.dimen[p.index] = v
|
|
|
|
end
|
|
|
|
else
|
|
|
|
return texmetaoldnewindex(t, k, v)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2019-07-17 21:14:34 +02:00
|
|
|
}
|
|
|
|
\def\InternalAlloc#1#2#3#4#5{%
|
|
|
|
\csname new#3\endcsname#1%
|
|
|
|
\global#1=#5\relax
|
2019-07-18 13:10:33 +02:00
|
|
|
\etoksapp0{#2_params["\luaescapestring{#4}"] = frozen"\luaescapestring{\csstring#1}"}
|
2019-07-17 21:14:34 +02:00
|
|
|
}
|
|
|
|
\def\internalAlloc#1#2#3{%
|
|
|
|
\expandafter\InternalAlloc\csname ^^^^fffe#3@#1\endcsname{#1}{#2}{#3}%
|
|
|
|
}
|
|
|
|
\def\texAlloc#1#2{%
|
|
|
|
\expandafter\InternalAlloc\csname #2\endcsname{tex}{#1}{#2}%
|
|
|
|
}
|
2019-07-18 13:10:33 +02:00
|
|
|
\def\pdfAlloc{%
|
|
|
|
\internalAlloc{pdf}%
|
|
|
|
}
|
2019-07-25 13:17:38 +02:00
|
|
|
\texAlloc{count}{suppressfontnotfounderror}{0}
|
2019-07-21 14:19:05 +02:00
|
|
|
\texAlloc{count}{outputmode}{1} % The "traditional" default would be 0,
|
|
|
|
% but we do not actually support that.
|
2020-01-02 04:14:39 +01:00
|
|
|
\texAlloc{dimen}{pageheight}{297mm}
|
|
|
|
\texAlloc{dimen}{pagewidth}{210mm}
|
2019-07-18 13:10:33 +02:00
|
|
|
\pdfAlloc{dimen}{horigin}{1in}
|
|
|
|
\pdfAlloc{dimen}{vorigin}{1in}
|
2019-07-24 18:04:04 +02:00
|
|
|
\pdfAlloc{count}{majorversion}{1}
|
2019-07-25 13:17:38 +02:00
|
|
|
\pdfAlloc{count}{minorversion}{7}
|
2020-01-02 04:14:39 +01:00
|
|
|
\pdfAlloc{count}{compresslevel}{0} % 0 is actually the only supported value right now, so this is basically ignored
|
|
|
|
\pdfAlloc{count}{objcompresslevel}{0} % see above
|
2019-07-17 21:14:34 +02:00
|
|
|
\directlua{
|
2019-07-18 13:10:33 +02:00
|
|
|
lua.prepared_code[\csstring#lua.prepared_code+1] = tex.toks[0] .. "end"
|
2019-07-17 21:14:34 +02:00
|
|
|
\the\toks0
|
2019-07-18 13:10:33 +02:00
|
|
|
end
|
2019-07-17 21:14:34 +02:00
|
|
|
}
|
|
|
|
\endgroup
|