[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: cleaning up guards (5c8e95f)

Ulrike Fischer fischer at troubleshooting-tex.de
Tue Jul 7 19:16:18 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : splitting
Link       : https://github.com/latex3/pdfresources/commit/5c8e95f43658e62f8855c54bedbc3d736b91daaa

>---------------------------------------------------------------

commit 5c8e95f43658e62f8855c54bedbc3d736b91daaa
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Tue Jun 16 00:54:45 2020 +0200

    cleaning up guards


>---------------------------------------------------------------

5c8e95f43658e62f8855c54bedbc3d736b91daaa
 l3pdfdict.dtx    |  42 ++++++++++--------
 pdfresources.dtx | 131 +++++++++++++++++++++++++++++--------------------------
 2 files changed, 94 insertions(+), 79 deletions(-)

diff --git a/l3pdfdict.dtx b/l3pdfdict.dtx
index 532bf28..ba6188d 100644
--- a/l3pdfdict.dtx
+++ b/l3pdfdict.dtx
@@ -71,6 +71,7 @@
 %  xform\ldots                           & argument of \cs{pdfxform} &local\\
 %  annot\ldots                           & argument of \cs{pdfannot},
 %                                          \cs{pdfstartlink} &local\\
+%  trans                                 & for transitions (used in hyperref)
 %  \end{tabular}
 % \end{NOTE}
 % \subsection{User Commands}
@@ -89,16 +90,17 @@
 %   {\pdfdict_name:n,\pdfdict_gname:n}
 %   \begin{syntax}
 %     \cs{pdfdict_name:n}  \Arg{local dictionary name}\\
-%     \cs{pdfdict_gname:n} \Arg{global dictionary name}\\
+%     \cs{pdfdict_gname:n} \Arg{global dictionary name}
 %   \end{syntax}
-% This expands to the internal name. With it it is possible to use standard commands
-% of the \texttt{prop} module to deal with the dictionaries. For example\\
+% These command expand to the internal name. With these commands
+% it is possible to use standard commands of the \texttt{prop} module
+% to deal with the dictionaries. For example\\
 % |\prop_clear:c { \pdfdict_name:n { name }}|
 % \end{function}
 % \begin{function}[added = 2020-04-06]
 %   {\pdfdict_put:nnn, \pdfdict_gput:nnn}
 %   \begin{syntax}
-%     \cs{pdfdict_put:nnn} \Arg{local dictionary} \Arg{name} \Arg{value} \\
+%     \cs{pdfdict_put:nnn}  \Arg{local dictionary}  \Arg{name} \Arg{value} \\
 %     \cs{pdfdict_gput:nnn} \Arg{global dictionary} \Arg{name} \Arg{value}
 %   \end{syntax}
 % This function puts \Arg{name} \Arg{value} locally or globally in the
@@ -126,7 +128,7 @@
 %   This can be used e.g. when writing a dictionary object with
 %   \cs{pdf_object_write:nx}
 % \end{function}
-%  \begin{function}[added = 2020-04-08]
+% \begin{function}[added = 2020-04-08]
 %   {\pdfdict_show:n }
 %   \begin{syntax}
 %     \cs{pdfdict_show:n}  \Arg{dictionary}
@@ -136,27 +138,27 @@
 %   exists it will show both.
 %\end{function}
 %\begin{function}[EXP, pTF,added = 2020-04-08]
-%   {\pdfdict_if_exist:n, \pdfdict_if_gexist:n,  }
+%   { \pdfdict_if_exist:n, \pdfdict_if_gexist:n  }
 %   \begin{syntax}
-%     \cs{pdfdict_if_exist:n}  \Arg{local dictionary}\\
+%     \cs{pdfdict_if_exist:n}   \Arg{local dictionary}\\
 %     \cs{pdfdict_if_gexist:n}  \Arg{global dictionary}
 %   \end{syntax}
 %   This tests if the dictionary exists.
-%\end{function}
+% \end{function}
 % \begin{function}[EXP, pTF,added = 2020-04-08]
-%   {\pdfdict_if_empty:n, \pdfdict_if_gempty:n }
+%   { \pdfdict_if_empty:n, \pdfdict_if_gempty:n }
 %   \begin{syntax}
 %     \cs{pdfdict_if_empty:n}  \Arg{local dictionary}\\
 %     \cs{pdfdict_if_gempty:n}  \Arg{global dictionary}
 %   \end{syntax}
 %   This tests if the dictionary is empty. The result is false if the
 %   dictionary doesn't exist.
-%\end{function}
+% \end{function}
 % \begin{function}[added = 2020-04-07]
 %   {\pdfdict_get:nn \pdfdict_gget:nn  }
 %   \begin{syntax}
-%     \cs{pdfdict_get:nnN}  \Arg{local dictionary} \Arg{name} \meta{tl var}\\
-%     \cs{pdfdict_gget:nnN}  \Arg{global dictionary} \Arg{name} \meta{tl var}\\
+%     \cs{pdfdict_get:nnN}  \Arg{local dictionary}  \Arg{name} \meta{tl var}\\
+%     \cs{pdfdict_gget:nnN} \Arg{global dictionary} \Arg{name} \meta{tl var}
 %   \end{syntax}
 %   Recovers the \meta{value} stored by \cs{pdfdict_put:nnn} and
 %   \cs{pdfdict_gput:nnn}
@@ -166,14 +168,14 @@
 %   to the special marker \cs{q_no_value}. \meta{name} is first converted
 %   with \cs{str_convert_pdfname}.  The \meta{token list
 %   variable} is set within the current \TeX{} group.
-%\end{function}
+% \end{function}
 % \begin{function}[added = 2020-04-07]
 %   {
-%     \pdfdict_remove:nn, \pdfdict_gremove:nn,
+%     \pdfdict_remove:nn, \pdfdict_gremove:nn
 %   }
 %   \begin{syntax}
-%     \cs{pdfdict_remove:nn} \Arg{local dictionary} \Arg{name}\\
-%     \cs{pdfdict_gremove:nn} \Arg{global dictionary} \Arg{name}\\
+%     \cs{pdfdict_remove:nn}  \Arg{local dictionary}  \Arg{name}\\
+%     \cs{pdfdict_gremove:nn} \Arg{global dictionary} \Arg{name}
 %   \end{syntax}
 %   Removes  |/|\meta{name} and its associated \meta{value} from
 %   the \Arg{dictionary}
@@ -191,7 +193,7 @@
 %   \begin{syntax}
 %     \cs{pdfdict_item:nn} \Arg{name} \Arg{value}
 %   \end{syntax}
-%   This outputs the arguments as needed in PDF dictionay by adding a slash
+%   This outputs the arguments as needed in a PDF dictionary by adding a slash
 %   before the name: |/|\Arg{name} \Arg{value}. It doesn't do any conversion or
 %   escaping. It does nothing if \Arg{value} is empty.
 % \end{function}
@@ -204,11 +206,15 @@
 %<*package>
 \ProvidesExplPackage {l3pdfdict} {2020-04-08} {0.5}
   {Tools for PDF dictionaries}
+%</package>
 %    \end{macrocode}
 % \subsection{messages}
 %    \begin{macrocode}
+%<*package>
 \msg_new:nnn  { pdfdict } { show-dict }
-  {
+  { %#1: name of the dictionary
+    %#2: expanded content
+    %#3: "local" or "global"
     The~#3~dictionary~'#1'~
     \tl_if_empty:nTF {#2}
       { is~empty \\>~ . }
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 920a281..aa07efc 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -37,18 +37,17 @@
 %<@@=pdf>
 %<*package>
 \RequirePackage{xparse,l3pdf}
-%\RequirePackage{tmpl3shipout}
 \RequirePackage{lthooks,zref-lastpage,bitset}
-\ProvidesExplPackage {pdfresources} {2020-04-08} {0.5}
+\ProvidesExplPackage {pdfresources} {2020-06-15} {0.6}
   {experimental pdf-resource management}
 \DeclareOption { debug }
   {
-    %\msg_redirect_module:nnn { pdf } { warning }{ error }
     \msg_redirect_module:nnn { pdf } { none } { warning }
   }
 \bool_new:N\g_@@_patches_bool
 \DeclareOption { patches }{\bool_gset_true:N\g_@@_patches_bool}
 \ProcessOptions\relax
+%</package>
 %    \end{macrocode}
 %
 % \title{\pkg{pdfresources}}
@@ -82,12 +81,13 @@
 %
 % \section{messages}
 %    \begin{macrocode}
+%<*package>
 \msg_new:nnn  { pdf } { patches }
               { loading~patch~code }
 \msg_new:nnn  { pdf } { pgf-too-late }
               { pgf~is~already~loaded.~Patching~not~possible.}
 
-% pdfdict module
+%</package>
 %    \end{macrocode}
 % \section{Preparation/helper Code}
 %^^A still needed:
@@ -96,45 +96,49 @@
 % \begin{variable}{\l_@@_tmpa_prop, \l_@@_tmpa_tl }
 % Some scratch variables
 %    \begin{macrocode}
+%<*package>
 \prop_new:N \l_@@_tmpa_prop
 \prop_new:N \g_@@_tmpa_prop
 \tl_new:N   \l_@@_tmpa_tl
 \box_new:N  \l_@@_tmpa_box
 \box_new:N  \l_@@_tmpb_box
+%</package>
 %    \end{macrocode}
 % \end{variable}
-%</package>
 % \subsection{some zref code, needs to be replaced later}
-%<*drivers>
 % \begin{variable}
 %  {\g_@@_backend_resourceid_int, \g_@@_backend_name_int, \g_@@_backend_page_int}
 %  a counter to create labels for the resources, a counter
 %  to number properties in bdc marks, a counter for the \cs{pdfpageref} implementation.
 %    \begin{macrocode}
+%<*drivers>
 \int_new:N \g_@@_backend_resourceid_int
 \int_new:N \g_@@_backend_name_int
 \int_new:N \g_@@_backend_page_int
+%</drivers>
 %    \end{macrocode}
 % \end{variable}
-%</drivers>
-%<*package>
-% a reference for the absolute page counter
+% a reference for the absolute page counter. This use the counter from the
+% new lthooks/ltshipout package.
 %    \begin{macrocode}
+%<*package>
 \zref at newlist  { l3pdf }
 \zref at newprop* { pdf at abspage } [0] { \int_use:N \g_shipout_readonly_int }
 \zref at addprop  { l3pdf } { pdf at abspage }
-%    \end{macrocode}
 %</package>
+%    \end{macrocode}
+%
 % \subsection{luacode}
-%<*pdfmode>
 % Load the lua code.
 %    \begin{macrocode}
+%<*pdfmode>
 \sys_if_engine_luatex:T
   {
     \directlua { require("pdfresources.lua") }
   }
-%    \end{macrocode}
 %</pdfmode>
+%    \end{macrocode}
+%
 % \subsection{shipout and end of run code}
 % Code is executed in three places: At shipout of every page,
 % at shipout of the last page, at the end of the document
@@ -153,28 +157,36 @@
 % With pdflatex/lualatex |AtEndDocument{\clearpage|\meta{code}|}| is used,
 % so the code is executed at the first compilation.
 % To avoid that specials are lost the code is added to
-% \cs{@@_BACKEND_lastpage_shipout_code_tl} with dvips/dvipdfmx and so needs a
+% \cs{\g_@@_backend_lastpage_shipout_code_tl} with dvips/dvipdfmx and so needs a
 % second compilation.
 % ++++++++++++++++
-%<*drivers>
 % \begin{variable}
 %   {
 %    \g_@@_backend_end_run_tl,
 %    \g_@@_backend_lastpage_shipout_tl,
 %    \g_@@_backend_thispage_shipout_tl
 %   }
+% This variables contain the code run in the three place.
 %    \begin{macrocode}
-%  for all:
+%<*drivers>
 \tl_new:N\g_@@_backend_end_run_tl
 \tl_new:N\g_@@_backend_lastpage_shipout_tl
 \tl_new:N\g_@@_backend_thispage_shipout_tl
+%</drivers>
 %    \end{macrocode}
 % \end{variable}
-% \begin{macro}{\@@_BACKEND_end_run_gput:n,
-%               \@@_BACKEND_lastpage_shipout_gput:n,
-%               \@@_BACKEND_thispage_shipout_gput:n
-%               }
+% \begin{macro}
+%   {
+%     \@@_BACKEND_end_run_gput:n,
+%     \@@_BACKEND_lastpage_shipout_gput:n,
+%     \@@_BACKEND_thispage_shipout_gput:n
+%   }
+% These are the commands used to fill the three hook variables.
+% \begin{NOTE}{UF}
+% Check if these should be done with real hooks.
+% \end{NOTE}
 %    \begin{macrocode}
+%<*drivers>
 \cs_new_protected:Npn \@@_BACKEND_end_run_gput:n #1
   {
     \tl_gput_right:Nn \g_@@_backend_end_run_tl { #1 }
@@ -190,62 +202,50 @@
     \tl_gput_right:Nn \g_@@_backend_thispage_shipout_tl { #1 }
   }
 %    \end{macrocode}
-% \end{macro}
 %</drivers>
-% \begin{macro}{\@@_BACKEND_end_run:}
-% This command setups the hook for the end of run code. At the end
-% it can perhaps go and only the hook stay, so leave it in uppercase for now.
+% \end{macro}
+% Here we add the end run token list to suitable
+% end hooks.
 %    \begin{macrocode}
 %<*pdfmode>
-% pdftex,luatex
-\cs_new_protected:Npn \@@_BACKEND_end_run:
+\hook_gput_code:nnn {enddocument/afterlastpage}
+  {pdf/endrun}
   {
-    \hook_gput_code:nnn {enddocument/afterlastpage}
-      {pdf}
-      {
-        \g_@@_backend_end_run_tl
-      }
+    \g_@@_backend_end_run_tl
   }
 %</pdfmode>
 %<*xdvipdfmx>
-\cs_new_protected:Npn \@@_BACKEND_end_run:
+\hook_gput_code:nnn {shipout/lastpage}
+  {pdf/endrun}
   {
-    \hook_gput_code:nnn {shipout/lastpage}
-      {pdf_endrun}
-      {
-        \g_@@_backend_end_run_tl
-      }
-    \hook_gset_rule:nnnn {shipout/lastpage}{pdf}{<}{pdf_endrun}
+    \g_@@_backend_end_run_tl
   }
-
+\hook_gset_rule:nnnn {shipout/lastpage}{pdf}{<}{pdf/endrun}
 %</xdvipdfmx>
 %<*dvips>
-\cs_new_protected:Npn \@@_BACKEND_end_run:
+\hook_gput_code:nnn {shipout/lastpage}
+  {pdf/endrun}
   {
-    \hook_gput_code:nnn {shipout/lastpage}
-      {pdf_endrun}
-      {
-        \g_@@_backend_end_run_tl
-      }
-    \hook_gset_rule:nnnn {shipout/lastpage}{pdf}{<}{pdf_endrun}
+    \g_@@_backend_end_run_tl
   }
+\hook_gset_rule:nnnn {shipout/lastpage}{pdf}{<}{pdf/endrun}
 %</dvips>
 %    \end{macrocode}
-%<*drivers>
-% now run the command to setup the hooks:
-%    \begin{macrocode}
-\@@_BACKEND_end_run:
-%    \end{macrocode}
-% \end{macro}
 % Now we add to the shipout hooks the relevant token lists.
 %    \begin{macrocode}
+%<*drivers>
 \hook_gput_code:nnn{shipout/background}{pdf}
-  {\g_@@_backend_thispage_shipout_tl}
+  { \g_@@_backend_thispage_shipout_tl }
 \hook_gput_code:nnn {shipout/lastpage} {pdf}
-  {\g_@@_backend_lastpage_shipout_tl}
+  { \g_@@_backend_lastpage_shipout_tl }
+%</drivers>
 %    \end{macrocode}
 % Here we fill the shipout hooks with content. For now
+% \begin{NOTE}{UF}
+% Check the names here, this is still a bit messy ...
+% \end{NOTE}
 %    \begin{macrocode}
+%<*drivers>
 \@@_BACKEND_thispage_shipout_gput:n
   {
     \exp_args:NV \@@_backend_ThisPage_gpush:n      { \g_shipout_readonly_int }
@@ -265,10 +265,9 @@
     \__pdfgdict_Info_gpush:             %pdfinfo
     \__pdfgdict_Catalog_gpush:
   }
+%</drivers>
 %    \end{macrocode}
 %
-%</drivers>
-%<*package>
 % \subsection{references to page objects}
 % \begin{NOTE}{UF}
 % a reference to the current page would be useful, but difficult to
@@ -285,26 +284,36 @@
 % \end{function}
 % \begin{macro}{ \pdf_pageobject_ref:n }
 %    \begin{macrocode}
+%<*package>
 \cs_new:Npn \pdf_pageobject_ref:n #1 { \@@_backend_pageobject_ref:n { #1 }}
+%</package>
 %    \end{macrocode}
 % \end{macro}
-%</package>
-%<*package>
+% This loads the dict packages.
+% \begin{NOTE}{UF}
+% The loading order must be sorted ...
+% \end{NOTE}
 %    \begin{macrocode}
+%<*package>
 \RequirePackage{l3pdfdict}
 \RequirePackage{l3pdfgdict}
-
+%</package>
 %    \end{macrocode}
-
+%
 % \subsection{Convenience local dictionaries}
+% \begin{NOTE}{UF}
+% This must be reviewed and sorted along with other dictionaries.
+% Perhaps it should move into l3pdfdict.
+% \end{NOTE}
 % A number of predefined small, local dictionaries, that are perhaps needed.
 % \subsubsection{page/Trans}
 % This is a template for a Trans dictionary that can be used in a page dictionary.
 %    \begin{macrocode}
+%<*package>
 \pdfdict_new:n {page/Trans}
 \pdfdict_put:nnn {page/Trans}{Type}{/Trans}
- %keys: /S (name), /D integer, /Dm (name), /M (name), /SS number /B boolean.
- %decribes transition *to* the page.
+% keys: /S (name), /D integer, /Dm (name), /M (name), /SS number /B boolean.
+% decribes transition *to* the page.
 %    \end{macrocode}
 % \subsubsection{annot/Link}
 % The dictionaries \texttt{annot/Link/URI}, \texttt{annot/Link/GoToR},





More information about the latex3-commits mailing list.