Debian Codegraph @

texmf-dist/source/latex/memoize-ext/memoize-ext-sockets.dtx

raw
1 % \iffalse meta-comment
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % memoize-ext.dtx
4 % Additions and changes Copyright (C) 2024-2026 Clea F. Rees.
5 % Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below).
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either version 1.3c
9 % of this license or (at your option) any later version.
10 % The latest version of this license is in
11 % https://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2008-05-04 or later.
14 %
15 % This work has the LPPL maintenance status 'muaintained'.
16 %
17 % The Current Maintainer of this work is Clea F. Rees.
18 %
19 % This work consists of all files listed in manifest.txt.
20 %
21 % The file memoize-ext.dtx is a derived work under the terms of the
22 % LPPL. It is based on version 2.4 of skeleton.dtx which is part of
23 % dtxtut by Scott Pakin. A copy of dtxtut, including the
24 % unmodified version of skeleton.dtx is available from
25 % https://www.ctan.org/pkg/dtxtut and released under the LPPL.
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 % \fi
28 %
29 % \iffalse
30 %<*driver>
31 \GetIdInfo $Id: memoize-ext-sockets.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
32 \ProvidesExplFile{\ExplFileName}{\ExplFileDate}{v0.3.5 \ExplFileVersion}{\ExplFileDescription}
33 \begin{document}
34 \let\MakePrivateLetters\MyMakePrivateLetters
35 \DocInput{\filename}
36 \end{document}
37 %</driver>
38 % \fi
39 %
40 % \title{\ExplFileName}
41 % \date{\ExplFileVersion~\ExplFileDate}
42 % \maketitle
43 %
44 % \begin{abstract}
45 % \noindent\pkg{memoize-ext-sockets} is part of \pkg{memoize-ext}.
46 % \end{abstract}
47 %
48 %
49 % \tableofcontents
50 %
51 %
52 % \MaybeStop{%
53 % \PrintChanges
54 % \PrintIndex
55 % }
56 %
57 % ^^A \section{Implementation}
58 %
59 %<*sty>
60 %<@@=mmzx>
61 % ^^A % \begin{macrocode}
62 % ^^A \SetDefaultHookLabel{memoize-ext}
63 % ^^A % \end{macrocode}
64 % ^^A \begin{macrocode}
65 % ^^A \GetIdInfo $Id: memoize-ext-sockets.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
66 % ^^A \ProvidesExplPackage{\ExplFileName}{\ExplFileDate}{v0.3.5 \ExplFileVersion}{\ExplFileDescription}
67 % ^^A \end{macrocode}
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % ltsockets
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 % ^^A % \begin{fn}{\@@_socket_replicate:n,\@@_socket_replicate:nw}
72 % ^^A % Write socket to memo, derive ‘base’ name of the current plug, assign it, use it and re-assign original plug\footnote{I suspect this is exactly the sort of thing sockets are not supposed to be for --- certainly hooks would be simpler \dots.}
73 % ^^A % \begin{macrocode}
74 % ^^A \cs_new:Npn \@@_socket_replicate:nw #1#2 \q_@@_stop
75 % ^^A {
76 % ^^A \@@_socket_to_ccmemo:nw {#1}#2 \q_@@_stop
77 % ^^A \str_set:Ne \l_@@_tmpb_str {\@@_socket_assigned_plug:n {#1}}
78 % ^^A \str_set:Ne \l_@@_tmpa_str {\exp_after:wN \@@_socket_plug_base:w \l_@@_tmpb_str \q_stop}
79 % ^^A \socket_assign_plug:NV {#1} \l_@@_tmpa_str
80 % ^^A \socket_use:nw {#1}#2
81 % ^^A \socket_assign_plug:NV {#1} \l_@@_tmpb_str
82 % ^^A }
83 % ^^A \cs_new:Npn \@@_socket_replicate:n #1
84 % ^^A {
85 % ^^A \@@_socket_replicate:nw {#1} \q_@@_stop
86 % ^^A % ^^A \@@_socket_to_ccmemo:n {#1}
87 % ^^A % ^^A \str_set:Ne \l_@@_tmpb_str {\@@_socket_assigned_plug:n {#1}}
88 % ^^A % ^^A \str_set:Ne \l_@@_tmpa_str {\exp_after:wN \@@_socket_plug_base:w \l_@@_tmpb_str \q_stop}
89 % ^^A % ^^A \socket_assign_plug:nV {#1} \l_@@_tmpa_str
90 % ^^A % ^^A \socket_use:n {#1}
91 % ^^A % ^^A \socket_assign_plug:nV {#1} \l_@@_tmpb_str
92 % ^^A }
93 % ^^A % \end{macrocode}
94 % ^^A % \end{fn}
95 % ^^A % \begin{fn}{\@@_socket_to_ccmemo:n,\@@_socket_to_ccmemo:nw}
96 % ^^A % Replicate socket.
97 % ^^A % \begin{macrocode}
98 % ^^A % ^^A \cs_new:Npn \@@_socket_to_ccmemo:n #1
99 % ^^A % ^^A {
100 % ^^A % ^^A \xtoksapp\mmzCCMemo{\UseSocket \c_left_brace_str #1 \c_right_brace_str}
101 % ^^A % ^^A }
102 % ^^A \cs_new:Npn \@@_socket_to_ccmemo:nw #1#2 \q_@@_stop
103 % ^^A {
104 % ^^A \xtoksapp\mmzCCMemo
105 % ^^A {
106 % ^^A \UseSocket \c_left_brace_str #1 \c_right_brace_str
107 % ^^A \tl_to_str:n {#2}
108 % ^^A }
109 % ^^A }
110 % ^^A % \end{macrocode}
111 % ^^A % \end{fn}
112 % ^^A % Simple variant.
113 % ^^A % \begin{macrocode}
114 % ^^A \cs_generate_variant:Nn \socket_assign_plug:nn {nV}
115 % ^^A % \end{macrocode}
116 % \begin{fn}{\@@_socket_assigned_plug:n}
117 % Returns the name of the plug assigned to the specified socket.
118 % This ought not use a variable internal to the format's code, but there does not seem to be a public interface.
119 % So it may break, but for now it works.
120 % \begin{macrocode}
121 \cs_new_nopar:Npn \@@_socket_assigned_plug:n #1
122 { % rhybudd: fn mewnol
123 \str_use:c { l__socket_#1_plug_str }
124 }
125 % \end{macrocode}
126 % \end{fn}
127 % ^^A % \begin{fn}{\@@_socket_plug_base:w}
128 % ^^A % Removes this module's prefix from a specified plug name.
129 % ^^A % This is not generally safe, as it does no checking, but is only intended for internal use.
130 % ^^A % \begin{macrocode}
131 % ^^A \cs_new_nopar:Npn \@@_socket_plug_base:w #1/#2 \q_stop
132 % ^^A {
133 % ^^A \if_str_eq:eeF {#1}{mmzx}{#1/}
134 % ^^A #2
135 % ^^A }
136 % ^^A % \end{macrocode}
137 % ^^A % \end{fn}
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 %</sty>
140 %
141 %\Finale
142 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 %^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: