% \iffalse meta-comment
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% memoize-ext.dtx
% Additions and changes Copyright (C) 2024-2026 Clea F. Rees.
% Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008-05-04 or later.
%
% This work has the LPPL maintenance status 'muaintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of all files listed in manifest.txt.
%
% The file memoize-ext.dtx is a derived work under the terms of the
% LPPL. It is based on version 2.4 of skeleton.dtx which is part of
% dtxtut by Scott Pakin. A copy of dtxtut, including the
% unmodified version of skeleton.dtx is available from
% https://www.ctan.org/pkg/dtxtut and released under the LPPL.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \fi
%
% \iffalse
%<*driver>
\GetIdInfo $Id: memoize-ext-l3draw.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
\ProvidesExplFile{\ExplFileName}{\ExplFileDate}{v0.3.5 \ExplFileVersion}{\ExplFileDescription}
\begin{document}
\let\MakePrivateLetters\MyMakePrivateLetters
\DocInput{\filename}
\end{document}
%</driver>
% \fi
%
% \title{\ExplFileName}
% \date{\ExplFileVersion~\ExplFileDate}
% \maketitle
%
% \begin{abstract}
%   \noindent Support for auto-memoization of content created with \pkg{l3draw} \autocite{latex-project-l3draw}.
%   \pkg{memoize-ext-l3draw} is part of \pkg{memoize-ext}.
% \end{abstract}
%
% \tableofcontents
% 
% 
% \MaybeStop{%
% \PrintChanges
% \PrintIndex
% }
% 
% ^^A \section{Implementation}
%
%<*sty>
%<@@=mmzx>
%    \begin{macrocode}
\GetIdInfo $Id: memoize-ext-l3draw.dtx 11815 2026-03-25 19:50:49Z cfrees $ {Extensions for Memoize}
%<!debug>    \ProvidesExplPackage{\ExplFileName}{\ExplFileDate}
%<!debug>     {v0.3.5 \ExplFileVersion}{\ExplFileDescription}
%<debug>    \ProvidesExplPackage{\ExplFileName-debug}{\ExplFileDate}
%<debug>      {v0.3.5 \ExplFileVersion}{\ExplFileDescription}
%
%<!debug>    \disable@package@load {memoize-ext-l3draw-debug}
%<debug>    \disable@package@load {memoize-ext-l3draw}
{ Only~one~of~memoize-ext-l3draw~and~memoize-ext-l3draw-debug~
  should~be~loaded.
  Since~
%<!debug>    memoize-ext-l3draw
%<debug>    memoize-ext-l3draw-debug
  ~has~been~loaded,~I~will~ignore~your~request~for~
%<debug>    memoize-ext-l3draw
%<!debug>    memoize-ext-l3draw-debug
.}
% 
%<!debug>    \RequirePackage{memoize-ext}
%<debug>    \RequirePackage{memoize-ext-debug}
%<!debug>    \RequirePackage{memoize-ext-expl3}
%<debug>    \RequirePackage{memoize-ext-expl3-debug}
%    \end{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% l3draw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \begin{var}{\g_@@_draw_id_begin_int}
%   \changes{v0.3.4}{2026-03-15}{Save and compare \pkg{l3draw} id.}
%   Temporary \texttt{int}.
%    \begin{macrocode}
\int_new:N \g_@@_draw_id_begin_int
%    \end{macrocode}
% \end{var}
% \begin{fn}{\@@_advice_collect_draw_args:w}
%   The \pkg{l3draw} picture environment is essentially a function with a weird argument specification, so we use a custom collector.
%    \begin{macrocode}
\cs_new:Npn \@@_advice_collect_draw_args:w #1 \draw_end:
{
  \toks0={ #1 \draw_end: }
  \exp_args:No \AdviceInnerHandler {\the\toks0}
}
%    \end{macrocode}
% \end{fn}
% \begin{macro}{\AdviceCollectDrawArguments}
%   Public wrapper.
%    \begin{macrocode}
\cs_new:Npn \AdviceCollectDrawArguments{
  \toks0 = {}
  \@@_advice_collect_draw_args:w
}
%    \end{macrocode}
% \end{macro}
% \changes{v0.3.4}{2026-03-17}{Hopefully slightly saner code for incrementing \pkg{l3draw} id.}
% Default configuration.
% \changes{v0.3.4}{2026-03-15}{Replicate changes to \pkg{l3draw}'s id.}
% This replicates changes to \verb|\g_draw_id_int|, but does so by executing code at the start and end of \emph{every} memoization.
% There must be a more efficient way to do do this \dots.
%    \begin{macrocode}
\mmzset{%
  gincr~draw~id/.style={
    at~begin~memoization={
      \gtoksapp\mmzCCMemo 
      {
        \UseName{int_gincr:c} {g_draw_id_int} 
      }
    },
  },
  auto~csname={draw_begin:}{memoize,collector=\AdviceCollectDrawArguments,gincr~draw~id,},
  auto~csname={__draw_record_origin:}{run~if~memoizing,replicate~expl~fn,},
}
%    \end{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</sty>
% 
%\Finale
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>:
