[latex3-commits] [git/LaTeX3-latex3-latex3] split-pdfmode: Split pdfmode file into pdfTeX and LuaTeX versions (8a2ea2bb1)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Aug 13 17:32:57 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : split-pdfmode
Link : https://github.com/latex3/latex3/commit/8a2ea2bb13adbf0287ba56ba1b7ffeabc5c0ed7c
>---------------------------------------------------------------
commit 8a2ea2bb13adbf0287ba56ba1b7ffeabc5c0ed7c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Aug 13 16:07:42 2020 +0100
Split pdfmode file into pdfTeX and LuaTeX versions
This looks forward to possible luacolor-like approaches
and for tagging.
>---------------------------------------------------------------
8a2ea2bb13adbf0287ba56ba1b7ffeabc5c0ed7c
l3backend/l3backend-basics.dtx | 105 ++++++---
l3backend/l3backend-color.dtx | 28 ++-
l3backend/l3backend-pdf.dtx | 403 ++++++++++++++++++--------------
l3backend/l3backend.ins | 23 +-
l3kernel/testfiles/d3pdfmode.tlg | 4 +-
l3kernel/testfiles/d3xdvipdfmx.tlg | 4 +-
l3kernel/testfiles/m3expl001.luatex.tlg | 4 +-
l3kernel/testfiles/m3expl001.tlg | 4 +-
l3kernel/testfiles/m3expl002.luatex.tlg | 4 +-
l3kernel/testfiles/m3expl002.tlg | 4 +-
l3kernel/testfiles/m3expl003.luatex.tlg | 4 +-
l3kernel/testfiles/m3expl003.tlg | 4 +-
l3kernel/testfiles/m3expl004.luatex.tlg | 4 +-
l3kernel/testfiles/m3expl004.tlg | 4 +-
l3kernel/testfiles/m3expl006.luatex.tlg | 4 +-
l3kernel/testfiles/m3expl006.tlg | 4 +-
l3kernel/testfiles/m3expl007.tlg | 8 +-
l3kernel/testfiles/m3file001.tlg | 1 +
18 files changed, 373 insertions(+), 243 deletions(-)
diff --git a/l3backend/l3backend-basics.dtx b/l3backend/l3backend-basics.dtx
index 209b2a648..4bbcf7f29 100644
--- a/l3backend/l3backend-basics.dtx
+++ b/l3backend/l3backend-basics.dtx
@@ -68,7 +68,6 @@
% All the file identifiers are up-front so that they come out in the right
% place in the files.
% \begin{macrocode}
-%<*package>
\ProvidesExplFile
%<*dvipdfmx>
{l3backend-dvipdfmx.def}{2020-08-07}{}
@@ -83,14 +82,21 @@
{L3 backend support: dvisvgm}
%</dvisvgm>
%<*pdfmode>
+%<*luatex>
+ {l3backend-pdfmode-lautex.def}{2020-08-07}{}
+%</luatex>
+%<*pdftex>
+ {l3backend-pdfmode-pdftex.def}{2020-08-07}{}
+%</pdftex>
+%<*shared>
{l3backend-pdfmode.def}{2020-08-07}{}
+%</shared>
{L3 backend support: PDF mode}
%</pdfmode>
%<*xdvipdfmx>
{l3backend-xdvipdfmx.def}{2020-08-07}{}
{L3 backend support: xdvipdfmx}
%</xdvipdfmx>
-%</package>
% \end{macrocode}
%
% The order of the backend code here is such that we get somewhat logical
@@ -112,12 +118,15 @@
% }
% The one shared function for all backends is access to the basic
% \tn{special} primitive: it has slightly odd expansion behaviour
-% so a wrapper is provided.
+% so a wrapper is provided. We just have to exclude the subfiles for
+% \texttt{pdfmode}.
% \begin{macrocode}
+%<*!pdftex&!luatex>
\cs_new_eq:NN \__kernel_backend_literal:e \tex_special:D
\cs_new_protected:Npn \__kernel_backend_literal:n #1
{ \__kernel_backend_literal:e { \exp_not:n {#1} } }
\cs_generate_variant:Nn \__kernel_backend_literal:n { x }
+%</!pdftex&!luatex>
% \end{macrocode}
% \end{macro}
%
@@ -219,9 +228,27 @@
%
% The direct PDF backend covers both \pdfTeX{} and \LuaTeX{}. The latter
% renames and restructures the backend primitives but this can be handled
-% at one level of abstraction. As such, we avoid using two separate backends
-% for this material at the cost of some \texttt{x}-type definitions to get
-% everything expanded up-front.
+% at one level of abstraction. As such, we use one backend but where necessary
+% split it into two parts: this is handled using DocStrip as over time we
+% will need more Lua for the \LuaTeX{} case. The top-level file therefore
+% just sets up to load one or other engine-specific version. We branch
+% based on the modern \LuaTeX{} backend approach: if someone tries to
+% use the more recent backend features with an ancient \LuaTeX{}, they
+% are on their own.
+% \begin{macrocode}
+%<*shared>
+\cs_if_exist:NTF \tex_pdfextension:D
+ { \__kernel_sys_configuration_load:n { l3backend-pdfmode-luatex } }
+ { \__kernel_sys_configuration_load:n { l3backend-pdfmode-pdftex } }
+%</shared>
+% \end{macrocode}
+%
+% Everything else here is split into two parts, as this makes life
+% easier overall.
+%
+% \begin{macrocode}
+%<*!shared>
+% \end{macrocode}
%
% \begin{macro}{\__kernel_backend_literal_pdf:n, \__kernel_backend_literal_pdf:x}
% This is equivalent to \verb|\special{pdf:}| but the engine can
@@ -230,12 +257,15 @@
% Note that this is still inside the text (\texttt{BT} \dots \texttt{ET}
% block).
% \begin{macrocode}
-\cs_new_protected:Npx \__kernel_backend_literal_pdf:n #1
+\cs_new_protected:Npn \__kernel_backend_literal_pdf:n #1
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D literal }
- { \tex_pdfliteral:D }
- { \exp_not:N \exp_not:n {#1} }
+%<*luatex>
+ \tex_pdfextension:D literal
+%</luatex>
+%<*pdftex>
+ \tex_pdfliteral:D
+%</pdftex>
+ { \exp_not:n {#1} }
}
\cs_generate_variant:Nn \__kernel_backend_literal_pdf:n { x }
% \end{macrocode}
@@ -245,13 +275,15 @@
% Page literals are pretty simple. To avoid an expansion, we write out
% by hand.
% \begin{macrocode}
-\cs_new_protected:Npx \__kernel_backend_literal_page:n #1
+\cs_new_protected:Npn \__kernel_backend_literal_page:n #1
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D literal ~ }
- { \tex_pdfliteral:D }
- page
- { \exp_not:N \exp_not:n {#1} }
+%<*luatex>
+ \tex_pdfextension:D literal ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfliteral:D
+%</pdftex>
+ page { \exp_not:n {#1} }
}
% \end{macrocode}
% \end{macro}
@@ -259,17 +291,23 @@
% \begin{macro}{\__kernel_backend_scope_begin:, \__kernel_backend_scope_end:}
% Higher-level interfaces for saving and restoring the graphic state.
% \begin{macrocode}
-\cs_new_protected:Npx \__kernel_backend_scope_begin:
+\cs_new_protected:Npn \__kernel_backend_scope_begin:
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D save \scan_stop: }
- { \tex_pdfsave:D }
+%<*luatex>
+ \tex_pdfextension:D save \scan_stop:
+%</luatex>
+%<*pdftex>
+ \tex_pdfsave:D
+%</pdftex>
}
-\cs_new_protected:Npx \__kernel_backend_scope_end:
+\cs_new_protected:Npn \__kernel_backend_scope_end:
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D restore \scan_stop: }
- { \tex_pdfrestore:D }
+%<*luatex>
+ \tex_pdfextension:D restore \scan_stop:
+%</luatex>
+%<*pdftex>
+ \tex_pdfrestore:D
+%</pdftex>
}
% \end{macrocode}
% \end{macro}
@@ -279,18 +317,25 @@
% into the PDF. With \pdfTeX{} and \LuaTeX{} in direct PDF output mode there
% is a primitive for this, which only needs the rotation/scaling/skew part.
% \begin{macrocode}
-\cs_new_protected:Npx \__kernel_backend_matrix:n #1
+\cs_new_protected:Npn \__kernel_backend_matrix:n #1
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D setmatrix }
- { \tex_pdfsetmatrix:D }
- { \exp_not:N \exp_not:n {#1} }
+%<*luatex>
+ \tex_pdfextension:D setmatrix
+%</luatex>
+%<*pdftex>
+ \tex_pdfsetmatrix:D
+%</pdftex>
+ { \exp_not:n {#1} }
}
\cs_generate_variant:Nn \__kernel_backend_matrix:n { x }
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
+%</!shared>
+% \end{macrocode}
+%
+% \begin{macrocode}
%</pdfmode>
% \end{macrocode}
%
diff --git a/l3backend/l3backend-color.dtx b/l3backend/l3backend-color.dtx
index 6defac481..f5dedd1ab 100644
--- a/l3backend/l3backend-color.dtx
+++ b/l3backend/l3backend-color.dtx
@@ -225,20 +225,26 @@
{ \@@_backend_select:n { #1 ~ g ~ #1 ~ G } }
\cs_new_protected:Npn \@@_backend_select_rgb:n #1
{ \@@_backend_select:n { #1 ~ rg ~ #1 ~ RG } }
-\cs_new_protected:Npx \@@_backend_select:n #1
+\cs_new_protected:Npn \@@_backend_select:n #1
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D colorstack }
- { \tex_pdfcolorstack:D }
- \exp_not:N \l__kernel_color_stack_int push {#1}
- \group_insert_after:N \exp_not:N \@@_backend_reset:
+%<*luatex>
+ \tex_pdfextension:D colorstack
+%</luatex>
+%<*pdftex>
+ \tex_pdfcolorstack:D
+%</pdftex>
+ \l__kernel_color_stack_int push {#1}
+ \group_insert_after:N \@@_backend_reset:
}
-\cs_new_protected:Npx \@@_backend_reset:
+\cs_new_protected:Npn \@@_backend_reset:
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D colorstack }
- { \tex_pdfcolorstack:D }
- \exp_not:N \l__kernel_color_stack_int pop \scan_stop:
+%<*luatex>
+ \tex_pdfextension:D colorstack
+%</luatex>
+%<*pdftex>
+ \tex_pdfcolorstack:D
+%</pdftex>
+ \l__kernel_color_stack_int pop \scan_stop:
}
% \end{macrocode}
% \end{macro}
diff --git a/l3backend/l3backend-pdf.dtx b/l3backend/l3backend-pdf.dtx
index fb569f2c2..b21966518 100644
--- a/l3backend/l3backend-pdf.dtx
+++ b/l3backend/l3backend-pdf.dtx
@@ -755,28 +755,35 @@
% \begin{macro}{\@@_backend_annotation:nnnn}
% Simply pass the raw data through, just dealing with evaluation of dimensions.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_backend_annotation:nnnn #1#2#3#4
+\cs_new_protected:Npn \@@_backend_annotation:nnnn #1#2#3#4
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D annot ~ }
- { \tex_pdfannot:D }
- width ~ \exp_not:N \dim_eval:n {#1} ~
- height ~ \exp_not:N \dim_eval:n {#2} ~
- depth ~ \exp_not:N \dim_eval:n {#3} ~
+%<*luatex>
+ \tex_pdfextension:D annot ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfannot:D
+%</pdftex>
+ width ~ \dim_eval:n {#1} ~
+ height ~ \dim_eval:n {#2} ~
+ depth ~ \dim_eval:n {#3} ~
{#4}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_backend_annotation_last:}
-% A tiny amount of extra data gets added here.
+% A tiny amount of extra data gets added here; we use \texttt{x}-type
+% expansion to get the space in the right place and form.
% \begin{macrocode}
\cs_new:Npx \@@_backend_annotation_last:
{
\exp_not:N \int_value:w
- \cs_if_exist:NTF \tex_pdffeedback:D
- { \exp_not:N \tex_pdffeedback:D lastannot ~ }
- { \exp_not:N \tex_pdflastannot:D }
+%<*luatex>
+ \exp_not:N \tex_pdffeedback:D lastannot
+%</luatex>
+%<*pdftex>
+ \exp_not:N \tex_pdfannot:D
+%</pdftex>
\c_space_tl 0 ~ R
}
% \end{macrocode}
@@ -792,19 +799,25 @@
{ \@@_backend_link_begin:nnnw {#1} { goto~name } {#2} }
\cs_new_protected:Npn \@@_backend_link_begin_user:nnw #1#2
{ \@@_backend_link_begin:nnnw {#1} { user } {#2} }
-\cs_new_protected:Npx \@@_backend_link_begin:nnnw #1#2#3
+\cs_new_protected:Npn \@@_backend_link_begin:nnnw #1#2#3
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D startlink ~ }
- { \tex_pdfstartlink:D }
- attr {#1}
- #2 {#3}
+%<*luatex>
+ \tex_pdfextension:D startlink ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfstartlink:D
+%</pdftex>
+ attr {#1}
+ #2 {#3}
}
-\cs_new_protected:Npx \@@_backend_link_end:
+\cs_new_protected:Npn \@@_backend_link_end:
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D endlink \scan_stop: }
- { \tex_pdfendlink:D }
+%<*luatex>
+ \tex_pdfextension:D endlink \scan_stop:
+%</luatex>
+%<*pdftex>
+ \tex_pdfendlink:D
+%</pdftex>
}
% \end{macrocode}
% \end{macro}
@@ -817,9 +830,12 @@
\cs_new:Npx \@@_backend_link_last:
{
\exp_not:N \int_value:w
- \cs_if_exist:NTF \tex_pdffeedback:D
- { \exp_not:N \tex_pdffeedback:D lastlink ~ }
- { \exp_not:N \tex_pdflastlink:D }
+%<*luatex>
+ \exp_not:N \tex_pdffeedback:D lastlink
+%</luatex>
+%<*pdftex>
+ \exp_not:N \tex_pdflastlink:D
+%</pdftex>
\c_space_tl 0 ~ R
}
% \end{macrocode}
@@ -828,12 +844,15 @@
% \begin{macro}{\@@_backend_link_margin:n}
% A simple task: pass the data to the primitive.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_backend_link_margin:n #1
+\cs_new_protected:Npn \@@_backend_link_margin:n #1
{
- \cs_if_exist:NTF \tex_pdfvariable:D
- { \exp_not:N \tex_pdfvariable:D linkmargin }
- { \exp_not:N \tex_pdflinkmargin:D }
- \exp_not:N \dim_eval:n {#1} \scan_stop:
+%<*luatex>
+ \tex_pdfvariable:D linkmargin
+%</luatex>
+%<*pdftex>
+ \tex_pdflinkmargin:D
+%</pdftex>
+ \dim_eval:n {#1} \scan_stop:
}
% \end{macrocode}
% \end{macro}
@@ -844,13 +863,16 @@
% percentage, but we need to pass it as \emph{per mille}. The rectangle
% version is also easy as everything is build in.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_backend_destination:nn #1#2
+\cs_new_protected:Npn \@@_backend_destination:nn #1#2
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \exp_not:N \tex_pdfextension:D dest ~ }
- { \exp_not:N \tex_pdfdest:D }
+%<*luatex>
+ \tex_pdfextension:D dest ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfdest:D
+%</pdftex>
name {#1}
- \exp_not:N \str_case:nnF {#2}
+ \str_case:nnF {#2}
{
{ xyz } { xyz }
{ fit } { fit }
@@ -860,21 +882,24 @@
{ fith } { fith }
{ fitv } { fitv }
}
- { xyz ~ zoom \exp_not:N \fp_eval:n { #2 * 10 } }
+ { xyz ~ zoom \fp_eval:n { #2 * 10 } }
\scan_stop:
}
-\cs_new_protected:Npx \@@_backend_destination_box:nn #1#2
+\cs_new_protected:Npn \@@_backend_destination_box:nn #1#2
{
\group_begin:
\hbox_set:Nn \l_@@_internal_box {#2}
- \cs_if_exist:NTF \tex_pdfextension:D
- { \exp_not:N \tex_pdfextension:D dest ~ }
- { \exp_not:N \tex_pdfdest:D }
+%<*luatex>
+ \tex_pdfextension:D dest ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfdest:D
+%</pdftex>
name {#1}
fitr ~
- width \exp_not:N \box_wd:N \l_@@_internal_box
- height \exp_not:N \box_ht:N \l_@@_internal_box
- depth \exp_not:N \box_dp:N \l_@@_internal_box
+ width \box_wd:N \l_@@_internal_box
+ height \box_ht:N \l_@@_internal_box
+ depth \box_dp:N \l_@@_internal_box
\box_use:N \l_@@_internal_box
\group_end:
}
@@ -885,19 +910,25 @@
%
% \begin{macro}{\@@_backend_catalog_gput:nn, \@@_backend_info_gput:nn}
% \begin{macrocode}
-\cs_new_protected:Npx \@@_backend_catalog_gput:nn #1#2
+\cs_new_protected:Npn \@@_backend_catalog_gput:nn #1#2
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D catalog }
- { \tex_pdfcatalog:D }
- { / #1 ~ #2 }
+%<*luatex>
+ \tex_pdfextension:D catalog
+%</luatex>
+%<*pdftex>
+ \tex_pdfcatalog:D
+%</pdftex>
+ { / #1 ~ #2 }
}
-\cs_new_protected:Npx \@@_backend_info_gput:nn #1#2
+\cs_new_protected:Npn \@@_backend_info_gput:nn #1#2
{
- \cs_if_exist:NTF \tex_pdfextension:D
- { \tex_pdfextension:D info }
- { \tex_pdfinfo:D }
- { / #1 ~ #2 }
+%<*luatex>
+ \tex_pdfextension:D info
+%</luatex>
+%<*pdftex>
+ \tex_pdfinfo:D
+%</pdftex>
+ { / #1 ~ #2 }
}
% \end{macrocode}
% \end{macro}
@@ -916,26 +947,25 @@
% Declaring objects means reserving at the PDF level plus starting
% tracking.
% \begin{macrocode}
-\group_begin:
- \cs_set_protected:Npn \@@_tmp:w #1#2
- {
- \cs_new_protected:Npx \@@_backend_object_new:nn ##1##2
- {
- #1 reserveobjnum ~
- \int_const:cn
- { c_@@_backend_object_ \exp_not:N \tl_to_str:n {##1} _int }
- {#2}
- \prop_gput:Nnn \exp_not:N \g_@@_backend_object_prop {##1} {##2}
- }
- }
- \cs_if_exist:NTF \tex_pdfextension:D
- {
- \@@_tmp:w
- { \tex_pdfextension:D obj ~ }
- { \exp_not:N \tex_pdffeedback:D lastobj }
- }
- { \@@_tmp:w { \tex_pdfobj:D } { \tex_pdflastobj:D } }
-\group_end:
+\cs_new_protected:Npn \@@_backend_object_new:nn #1#2
+ {
+%<*luatex>
+ \tex_pdfextension:D obj ~
+%</luatex>
+%<*pdftex>
+ \tex_pdfobj:D
+%</pdftex>
+ reserveobjnum ~
+ \int_const:cn
+ { c_@@_backend_object_ \tl_to_str:n {#1} _int }
+%<*luatex>
+ { \tex_pdffeedback:D lastobj }
+%</luatex>
+%<*pdftex>
+ { \tex_pdflastobj:D }
+%</pdftex>
+ \prop_gput:Nnn \exp_not:N \g_@@_backend_object_prop {#1} {#2}
+ }
\cs_new:Npn \@@_backend_object_ref:n #1
{ \int_use:c { c_@@_backend_object_ \tl_to_str:n {#1} _int } ~ 0 ~ R }
% \end{macrocode}
@@ -947,36 +977,34 @@
% Writing the data needs a little information about the structure of the
% object.
% \begin{macrocode}
-\group_begin:
- \cs_set_protected:Npn \@@_tmp:w #1
- {
- \cs_new_protected:Npn \@@_backend_object_write:nn ##1##2
+\cs_new_protected:Npn \@@_backend_object_write:nn #1#2
+ {
+%<*luatex>
+ \tex_immediate:D \tex_pdfextension:D obj ~
+%</luatex>
+%<*pdftex>
+ \tex_immediate:D \tex_pdfobj:D
+%</pdftex>
+ useobjnum ~
+ \int_use:c
+ { c_@@_backend_object_ \tl_to_str:n {#1} _int }
+ \str_case_e:nn
+ { \prop_item:Nn \g_@@_backend_object_prop {#1} }
{
- \tex_immediate:D #1 useobjnum ~
- \int_use:c
- { c_@@_backend_object_ \tl_to_str:n {##1} _int }
- \str_case_e:nn
- { \prop_item:Nn \g_@@_backend_object_prop {##1} }
- {
- { array } { { [ ~ \exp_not:n {##2} ~ ] } }
- { dict } { { << ~ \exp_not:n {##2} ~ >> } }
- { fstream }
- {
- stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~
- file ~ { \@@_exp_not_ii:nn ##2 }
- }
- { stream }
- {
- stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~
- { \@@_exp_not_ii:nn ##2 }
- }
- }
+ { array } { { [ ~ \exp_not:n {#2} ~ ] } }
+ { dict } { { << ~ \exp_not:n {#2} ~ >> } }
+ { fstream }
+ {
+ stream ~ attr ~ { \@@_exp_not_i:nn #2 } ~
+ file ~ { \@@_exp_not_ii:nn #2 }
+ }
+ { stream }
+ {
+ stream ~ attr ~ { \@@_exp_not_i:nn #2 } ~
+ { \@@_exp_not_ii:nn #2 }
+ }
}
- }
- \cs_if_exist:NTF \tex_pdfextension:D
- { \@@_tmp:w { \tex_pdfextension:D obj ~ } }
- { \@@_tmp:w { \tex_pdfobj:D } }
-\group_end:
+ }
\cs_generate_variant:Nn \@@_backend_object_write:nn { nx }
\cs_new:Npn \@@_exp_not_i:nn #1#2 { \exp_not:n {#1} }
\cs_new:Npn \@@_exp_not_ii:nn #1#2 { \exp_not:n {#2} }
@@ -987,34 +1015,31 @@
% \begin{macro}{\@@_backend_object_now:nn, \@@_backend_object_now:nx}
% Much like writing, but direct creation.
% \begin{macrocode}
-\group_begin:
- \cs_set_protected:Npn \@@_tmp:w #1
- {
- \cs_new_protected:Npn \@@_backend_object_now:nn ##1##2
+\cs_new_protected:Npn \@@_backend_object_now:nn #1#2
+ {
+%<*luatex>
+ \tex_immediate:D \tex_pdfextension:D obj ~
+%</luatex>
+%<*pdftex>
+ \tex_immediate:D \tex_pdfobj:D
+%</pdftex>
+ \str_case:nn
+ {#1}
{
- \tex_immediate:D #1
- \str_case:nn
- {##1}
- {
- { array } { { [ ~ \exp_not:n {##2} ~ ] } }
- { dict } { { << ~ \exp_not:n {##2} ~ >> } }
- { fstream }
- {
- stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~
- file ~ { \@@_exp_not_ii:nn ##2 }
- }
- { stream }
- {
- stream ~ attr ~ { \@@_exp_not_i:nn ##2 } ~
- { \@@_exp_not_ii:nn ##2 }
- }
- }
+ { array } { { [ ~ \exp_not:n {#2} ~ ] } }
+ { dict } { { << ~ \exp_not:n {#2} ~ >> } }
+ { fstream }
+ {
+ stream ~ attr ~ { \@@_exp_not_i:nn #2 } ~
+ file ~ { \@@_exp_not_ii:nn #2 }
+ }
+ { stream }
+ {
+ stream ~ attr ~ { \@@_exp_not_i:nn #2 } ~
+ { \@@_exp_not_ii:nn #2 }
+ }
}
- }
- \cs_if_exist:NTF \tex_pdfextension:D
- { \@@_tmp:w { \tex_pdfextension:D obj ~ } }
- { \@@_tmp:w { \tex_pdfobj:D } }
-\group_end:
+ }
\cs_generate_variant:Nn \@@_backend_object_now:nn { nx }
% \end{macrocode}
% \end{macro}
@@ -1025,23 +1050,29 @@
\cs_new:Npx \@@_backend_object_last:
{
\exp_not:N \int_value:w
- \cs_if_exist:NTF \tex_pdffeedback:D
- { \exp_not:N \tex_pdffeedback:D lastobj ~ }
- { \exp_not:N \tex_pdflastobj:D }
+%<*luatex>
+ \exp_not:N \tex_pdffeedback:D lastobj ~
+%</luatex>
+%<*pdftex>
+ \exp_not:N \tex_pdflastobj:D
+%</pdftex>
\c_space_tl 0 ~ R
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_backend_pageobject_ref:n}
-% The usual wrapper situation.
+% The usual wrapper situation; the three spaces here are essential.
% \begin{macrocode}
\cs_new:Npx \@@_backend_pageobject_ref:n #1
{
\exp_not:N \int_value:w
- \cs_if_exist:NTF \tex_pdffeedback:D
- { \exp_not:N \tex_pdffeedback:D pageref }
- { \exp_not:N \tex_pdfpageref:D }
+%<*luatex>
+ \exp_not:N \tex_pdffeedback:D pageref
+%</luatex>
+%<*pdftex>
+ \exp_not:N \tex_pdfpageref:D
+%</pdftex>
\c_space_tl #1 \c_space_tl \c_space_tl \c_space_tl 0 ~ R
}
% \end{macrocode}
@@ -1054,13 +1085,16 @@
% \begin{macro}{\@@_backend_objcompresslevel:n}
% Simply pass data to the engine.
% \begin{macrocode}
-\cs_new_protected:Npx \@@_backend_compresslevel:n #1
+\cs_new_protected:Npn \@@_backend_compresslevel:n #1
{
- \exp_not:N \tex_global:D
- \cs_if_exist:NTF \tex_pdfcompresslevel:D
- { \tex_pdfcompresslevel:D }
- { \tex_pdfvariable:D compresslevel }
- \exp_not:N \int_value:w \exp_not:N \int_eval:n {#1} \scan_stop:
+ \tex_global:D
+%<*luatex>
+ \tex_pdfvariable:D compresslevel
+%</luatex>
+%<*pdftex>
+ \tex_pdfcompresslevel:D
+%</pdftex>
+ \int_value:w \int_eval:n {#1} \scan_stop:
}
\cs_new_protected:Npn \@@_backend_compress_objects:n #1
{
@@ -1068,13 +1102,16 @@
{ \@@_backend_objcompresslevel:n { 2 } }
{ \@@_backend_objcompresslevel:n { 0 } }
}
-\cs_new_protected:Npx \@@_backend_objcompresslevel:n #1
+\cs_new_protected:Npn \@@_backend_objcompresslevel:n #1
{
- \exp_not:N \tex_global:D
- \cs_if_exist:NTF \tex_pdfobjcompresslevel:D
- { \tex_pdfobjcompresslevel:D }
- { \tex_pdfvariable:D objcompresslevel }
- #1 \scan_stop:
+ \tex_global:D
+%<*luatex>
+ \tex_pdfvariable:D objcompresslevel
+%</luatex>
+%<*pdftex>
+ \tex_pdfobjcompresslevel:D
+%</pdftex>
+ #1 \scan_stop:
}
% \end{macrocode}
% \end{macro}
@@ -1083,61 +1120,65 @@
%
% \begin{macro}
% {\@@_backend_version_major_gset:n, \@@_backend_version_minor_gset:n}
-% At present, we don't have a primitive for the major version in \pdfTeX{},
-% but we anticipate one \ldots
+% The availability of the primitive is not universal, so we have to test
+% at load time.
% \begin{macrocode}
\cs_new_protected:Npx \@@_backend_version_major_gset:n #1
{
- \cs_if_exist:NTF \tex_pdfvariable:D
+%<*luatex>
+ \int_compare:nNnT \tex_luatexversion:D > { 106 }
{
- \int_compare:nNnT \tex_luatexversion:D > { 106 }
- {
- \exp_not:N \tex_global:D \tex_pdfvariable:D majorversion
- \exp_not:N \int_eval:n {#1} \scan_stop:
- }
+ \exp_not:N \tex_global:D \tex_pdfvariable:D majorversion
+ \exp_not:N \int_eval:n {#1} \scan_stop:
}
+%</luatex>
+%<*pdftex>
+ \cs_if_exist:NT \tex_pdfmajorversion:D
{
- \cs_if_exist:NT \tex_pdfmajorversion:D
- {
- \exp_not:N \tex_global:D \tex_pdfmajorversion:D
- \exp_not:N \int_eval:n {#1} \scan_stop:
- }
+ \exp_not:N \tex_global:D \tex_pdfmajorversion:D
+ \exp_not:N \int_eval:n {#1} \scan_stop:
}
+%</pdftex>
}
-\cs_new_protected:Npx \@@_backend_version_minor_gset:n #1
+\cs_new_protected:Npn \@@_backend_version_minor_gset:n #1
{
- \exp_not:N \tex_global:D
- \cs_if_exist:NTF \tex_pdfminorversion:D
- { \exp_not:N \tex_pdfminorversion:D }
- { \tex_pdfvariable:D minorversion }
- \exp_not:N \int_eval:n {#1} \scan_stop:
+ \tex_global:D
+%<*luatex>
+ \tex_pdfvariable:D minorversion
+%</luatex>
+%<*pdftex>
+ \tex_pdfminorversion:D
+%</pdftex>
+ \int_eval:n {#1} \scan_stop:
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_backend_version_major:, \@@_backend_version_minor:}
-% At present, we don't have a primitive for the major version!
+% As above.
% \begin{macrocode}
\cs_new:Npx \@@_backend_version_major:
{
- \cs_if_exist:NTF \tex_pdfvariable:D
- {
- \int_compare:nNnTF \tex_luatexversion:D > { 106 }
- { \exp_not:N \tex_the:D \tex_pdfvariable:D majorversion }
- { 1 }
- }
- {
- \cs_if_exist:NTF \tex_pdfmajorversion:D
- { \exp_not:N \tex_the:D \tex_pdfmajorversion:D }
- { 1 }
- }
+%<*luatex>
+ \int_compare:nNnTF \tex_luatexversion:D > { 106 }
+ { \exp_not:N \tex_the:D \tex_pdfvariable:D majorversion }
+ { 1 }
+%</luatex>
+%<*pdftex>
+ \cs_if_exist:NTF \tex_pdfmajorversion:D
+ { \exp_not:N \tex_the:D \tex_pdfmajorversion:D }
+ { 1 }
+%</pdftex>
}
-\cs_new:Npx \@@_backend_version_minor:
+\cs_new:Npn \@@_backend_version_minor:
{
- \exp_not:N \tex_the:D
- \cs_if_exist:NTF \tex_pdfminorversion:D
- { \exp_not:N \tex_pdfminorversion:D }
- { \tex_pdfvariable:D minorversion }
+ \tex_the:D
+%<*luatex>
+ \tex_pdfvariable:D minorversion
+%</luatex>
+%<*pdftex>
+ \tex_pdfminorversion:D
+%</pdftex>
}
% \end{macrocode}
% \end{macro}
diff --git a/l3backend/l3backend.ins b/l3backend/l3backend.ins
index 1c5289b11..b52628aed 100644
--- a/l3backend/l3backend.ins
+++ b/l3backend/l3backend.ins
@@ -97,13 +97,24 @@ and all files in that bundle must be distributed together.
\generate
{
\file{l3backend-pdfmode.def}
+ {\from{l3backend-basics.dtx} {package,pdfmode,shared}}
+ \file{l3backend-pdfmode-pdftex.def}
{
- \from{l3backend-basics.dtx} {package,pdfmode}
- \from{l3backend-color.dtx} {package,pdfmode}
- \from{l3backend-box.dtx} {package,pdfmode}
- \from{l3backend-draw.dtx} {package,pdfmode}
- \from{l3backend-graphics.dtx}{package,pdfmode}
- \from{l3backend-pdf.dtx} {package,pdfmode}
+ \from{l3backend-basics.dtx} {package,pdfmode,pdftex}
+ \from{l3backend-color.dtx} {package,pdfmode,pdftex}
+ \from{l3backend-box.dtx} {package,pdfmode,pdftex}
+ \from{l3backend-draw.dtx} {package,pdfmode,pdftex}
+ \from{l3backend-graphics.dtx}{package,pdfmode,pdftex}
+ \from{l3backend-pdf.dtx} {package,pdfmode,pdftex}
+ }
+ \file{l3backend-pdfmode-luatex.def}
+ {
+ \from{l3backend-basics.dtx} {package,pdfmode,luatex}
+ \from{l3backend-color.dtx} {package,pdfmode,luatex}
+ \from{l3backend-box.dtx} {package,pdfmode,luatex}
+ \from{l3backend-draw.dtx} {package,pdfmode,luatex}
+ \from{l3backend-graphics.dtx}{package,pdfmode,luatex}
+ \from{l3backend-pdf.dtx} {package,pdfmode,luatex}
}
}
\generate
diff --git a/l3kernel/testfiles/d3pdfmode.tlg b/l3kernel/testfiles/d3pdfmode.tlg
index e1ead4fc2..b748fa916 100644
--- a/l3kernel/testfiles/d3pdfmode.tlg
+++ b/l3kernel/testfiles/d3pdfmode.tlg
@@ -6,9 +6,11 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
File: l3debug.def ....-..-.. L3 Debugging support
) (l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
Author: Joseph Wright
============================================================
TEST 1: Clip box
diff --git a/l3kernel/testfiles/d3xdvipdfmx.tlg b/l3kernel/testfiles/d3xdvipdfmx.tlg
index 91fc5390c..2d947e9ee 100644
--- a/l3kernel/testfiles/d3xdvipdfmx.tlg
+++ b/l3kernel/testfiles/d3xdvipdfmx.tlg
@@ -14,9 +14,11 @@ You have requested backend 'xdvipdfmx', but this is not suitable for use with
the active engine. LaTeX3 will use the 'pdfmode' backend instead.
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
Author: Joseph Wright
============================================================
TEST 1: Clip box
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 53cd1b968..c6617c9c3 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -20,6 +20,8 @@ File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal:e on line ...
Defining \__kernel_backend_literal:n on line ...
Defining \__kernel_backend_literal:x on line ...
+(l3backend-pdfmode-luatex.def
+File: l3backend-pdfmode-lautex.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal_pdf:n on line ...
Defining \__kernel_backend_literal_pdf:x on line ...
Defining \__kernel_backend_literal_page:n on line ...
@@ -131,4 +133,4 @@ Defining \__pdf_backend_version_major: on line ...
Defining \__pdf_backend_version_minor: on line ...
Defining \__pdf_backend_bdc:nn on line ...
Defining \__pdf_backend_emc: on line ...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 53cd1b968..46ae08a71 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -20,6 +20,8 @@ File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal:e on line ...
Defining \__kernel_backend_literal:n on line ...
Defining \__kernel_backend_literal:x on line ...
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal_pdf:n on line ...
Defining \__kernel_backend_literal_pdf:x on line ...
Defining \__kernel_backend_literal_page:n on line ...
@@ -131,4 +133,4 @@ Defining \__pdf_backend_version_major: on line ...
Defining \__pdf_backend_version_minor: on line ...
Defining \__pdf_backend_bdc:nn on line ...
Defining \__pdf_backend_emc: on line ...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl002.luatex.tlg b/l3kernel/testfiles/m3expl002.luatex.tlg
index 16e2a7e72..9bb9d4bf5 100644
--- a/l3kernel/testfiles/m3expl002.luatex.tlg
+++ b/l3kernel/testfiles/m3expl002.luatex.tlg
@@ -6,6 +6,8 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
File: l3debug.def ....-..-.. L3 Debugging support
) (l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-luatex.def
+File: l3backend-pdfmode-lautex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl002.tlg b/l3kernel/testfiles/m3expl002.tlg
index 16e2a7e72..b410dabec 100644
--- a/l3kernel/testfiles/m3expl002.tlg
+++ b/l3kernel/testfiles/m3expl002.tlg
@@ -6,6 +6,8 @@ Package: expl3 ....-..-.. L3 programming layer (loader)
File: l3debug.def ....-..-.. L3 Debugging support
) (l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 53cd1b968..c6617c9c3 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -20,6 +20,8 @@ File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal:e on line ...
Defining \__kernel_backend_literal:n on line ...
Defining \__kernel_backend_literal:x on line ...
+(l3backend-pdfmode-luatex.def
+File: l3backend-pdfmode-lautex.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal_pdf:n on line ...
Defining \__kernel_backend_literal_pdf:x on line ...
Defining \__kernel_backend_literal_page:n on line ...
@@ -131,4 +133,4 @@ Defining \__pdf_backend_version_major: on line ...
Defining \__pdf_backend_version_minor: on line ...
Defining \__pdf_backend_bdc:nn on line ...
Defining \__pdf_backend_emc: on line ...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 53cd1b968..46ae08a71 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -20,6 +20,8 @@ File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal:e on line ...
Defining \__kernel_backend_literal:n on line ...
Defining \__kernel_backend_literal:x on line ...
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
Defining \__kernel_backend_literal_pdf:n on line ...
Defining \__kernel_backend_literal_pdf:x on line ...
Defining \__kernel_backend_literal_page:n on line ...
@@ -131,4 +133,4 @@ Defining \__pdf_backend_version_major: on line ...
Defining \__pdf_backend_version_minor: on line ...
Defining \__pdf_backend_bdc:nn on line ...
Defining \__pdf_backend_emc: on line ...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl004.luatex.tlg b/l3kernel/testfiles/m3expl004.luatex.tlg
index d57d42982..4fd28f231 100644
--- a/l3kernel/testfiles/m3expl004.luatex.tlg
+++ b/l3kernel/testfiles/m3expl004.luatex.tlg
@@ -4,6 +4,8 @@ Don't change this file in any respect.
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-luatex.def
+File: l3backend-pdfmode-lautex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl004.tlg b/l3kernel/testfiles/m3expl004.tlg
index d57d42982..787427c32 100644
--- a/l3kernel/testfiles/m3expl004.tlg
+++ b/l3kernel/testfiles/m3expl004.tlg
@@ -4,6 +4,8 @@ Don't change this file in any respect.
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl006.luatex.tlg b/l3kernel/testfiles/m3expl006.luatex.tlg
index a937ad84f..1462861f2 100644
--- a/l3kernel/testfiles/m3expl006.luatex.tlg
+++ b/l3kernel/testfiles/m3expl006.luatex.tlg
@@ -5,6 +5,8 @@ Author: Bruno Le Floch and Joseph Wright
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-luatex.def
+File: l3backend-pdfmode-lautex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl006.tlg b/l3kernel/testfiles/m3expl006.tlg
index a937ad84f..bff449c76 100644
--- a/l3kernel/testfiles/m3expl006.tlg
+++ b/l3kernel/testfiles/m3expl006.tlg
@@ -5,6 +5,8 @@ Author: Bruno Le Floch and Joseph Wright
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-))
+)))
diff --git a/l3kernel/testfiles/m3expl007.tlg b/l3kernel/testfiles/m3expl007.tlg
index 595b628bd..b6d9a65b4 100644
--- a/l3kernel/testfiles/m3expl007.tlg
+++ b/l3kernel/testfiles/m3expl007.tlg
@@ -5,11 +5,13 @@ Author: Phelype Oleinik
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3backend-pdfmode.def
File: l3backend-pdfmode.def ....-..-.. L3 backend support: PDF mode
+(l3backend-pdfmode-pdftex.def
+File: l3backend-pdfmode-pdftex.def ....-..-.. L3 backend support: PDF mode
\l__kernel_color_stack_int=\count...
\l__pdf_internal_box=\box...
-)) (expl3.sty
+)))
+(expl3.sty
Package: expl3 ....-..-.. L3 programming layer (loader)
(l3debug.def
File: l3debug.def ....-..-.. L3 Debugging support
-))
-(expl3.ltx)
+)) (expl3.ltx)
diff --git a/l3kernel/testfiles/m3file001.tlg b/l3kernel/testfiles/m3file001.tlg
index 2447d2ddf..b74369802 100644
--- a/l3kernel/testfiles/m3file001.tlg
+++ b/l3kernel/testfiles/m3file001.tlg
@@ -198,6 +198,7 @@ ot1enc.def
expl3.sty
l3debug.def
l3backend-<...>.def
+l3backend-<...>.def
filetest.txt
filetest-endinput.txt
.............
More information about the latex3-commits
mailing list.