Skip to content

Commit

Permalink
Avoid nesting \__draw_point_process:nn calls
Browse files Browse the repository at this point in the history
This makes the code clearer but also looks forward to using e-type expansion.
  • Loading branch information
josephwright committed Feb 10, 2019
1 parent 3861168 commit 4b1620b
Showing 1 changed file with 55 additions and 32 deletions.
87 changes: 55 additions & 32 deletions l3experimental/l3draw/l3draw-points.dtx
Expand Up @@ -93,39 +93,73 @@
% \subsection{Support functions}
%
% \begin{macro}[EXP]{\@@_point_process:nn}
% \begin{macro}[EXP]{\@@_point_process_auxi:nn, \@@_point_process_auxi:fn}
% \begin{macro}[EXP]{\@@_point_process_auxi:nn}
% \begin{macro}[EXP]{\@@_point_process_auxii:nw}
% \begin{macro}[EXP]{\@@_point_process:nnn}
% \begin{macro}[EXP]{\@@_point_process_auxiii:nnn, \@@_point_process_auxiii:ffn}
% \begin{macro}[EXP]{\@@_point_process_auxiii:nnn}
% \begin{macro}[EXP]{\@@_point_process_auxiv:nw}
% \begin{macro}[EXP]{\@@_point_process:nnnn}
% \begin{macro}[EXP]{\@@_point_process_auxv:nnnn}
% \begin{macro}[EXP]{\@@_point_process_auxvi:nw}
% \begin{macro}[EXP]{\@@_point_process:nnnnn}
% \begin{macro}[EXP]{\@@_point_process_auxvii:nnnnn}
% \begin{macro}[EXP]{\@@_point_process_auxviii:nw}
% Execute whatever code is passed to extract the $x$ and $y$ co-ordinates.
% The first argument here should itself absorb two arguments. There is
% also a version to deal with two co-ordinates: common enough to justify a
% separate function.
% \begin{macrocode}
\cs_new:Npn \@@_point_process:nn #1#2
{
\@@_point_process_auxi:fn
\exp_args:Nf \@@_point_process_auxi:nn
{ \@@_point_to_dim:n {#2} }
{#1}
}
\cs_new:Npn \@@_point_process_auxi:nn #1#2
{ \@@_point_process_auxii:nw {#2} #1 \q_stop }
\cs_generate_variant:Nn \@@_point_process_auxi:nn { f }
\cs_new:Npn \@@_point_process_auxii:nw #1 #2 , #3 \q_stop
{ #1 {#2} {#3} }
\cs_new:Npn \@@_point_process:nnn #1#2#3
{
\@@_point_process_auxiii:ffn
\exp_args:Nff \@@_point_process_auxiii:nnn
{ \@@_point_to_dim:n {#2} }
{ \@@_point_to_dim:n {#3} }
{#1}
}
\cs_new:Npn \@@_point_process_auxiii:nnn #1#2#3
{ \@@_point_process_auxiv:nw {#3} #1 \q_mark #2 \q_stop }
\cs_generate_variant:Nn \@@_point_process_auxiii:nnn { ff }
\cs_new:Npn \@@_point_process_auxiv:nw #1 #2 , #3 \q_mark #4 , #5 \q_stop
{ #1 {#2} {#3} {#4} {#5} }
\cs_new:Npn \@@_point_process:nnnn #1#2#3#4
{
\exp_args:Nfff \@@_point_process_auxv:nnnn
{ \@@_point_to_dim:n {#2} }
{ \@@_point_to_dim:n {#3} }
{ \@@_point_to_dim:n {#4} }
{#1}
}
\cs_new:Npn \@@_point_process_auxv:nnnn #1#2#3#4
{ \@@_point_process_auxvi:nw {#4} #1 \q_mark #2 \q_mark #3 \q_stop }
\cs_new:Npn \@@_point_process_auxvi:nw
#1 #2 , #3 \q_mark #4 , #5 \q_mark #6 , #7 \q_stop
{ #1 {#2} {#3} {#4} {#5} {#6} {#7} }
\cs_new:Npn \@@_point_process:nnnnn #1#2#3#4#5
{
\exp_args:Nffff \@@_point_process_auxvii:nnnnn
{ \@@_point_to_dim:n {#2} }
{ \@@_point_to_dim:n {#3} }
{ \@@_point_to_dim:n {#4} }
{ \@@_point_to_dim:n {#5} }
{#1}
}
\cs_new:Npn \@@_point_process_auxvii:nnnnn #1#2#3#4#5
{
\@@_point_process_auxviii:nw
{#5} #1 \q_mark #2 \q_mark #3 \q_mark #4 \q_stop
}
\cs_new:Npn \@@_point_process_auxviii:nw
#1 #2 , #3 \q_mark #4 , #5 \q_mark #6 , #7 \q_mark #8 , #9 \q_stop
{ #1 {#2} {#3} {#4} {#5} {#6} {#7} {#8} {#9} }
% \end{macrocode}
% \end{macro}
% \end{macro}
Expand Down Expand Up @@ -235,24 +269,21 @@
% \begin{macrocode}
\cs_new:Npn \draw_point_intersect_lines:nnnn #1#2#3#4
{
\@@_point_process:nnn
{
\@@_point_process:nnn
{ \@@_point_intersect_lines:nnnnnnnn } {#3} {#4}
}
{#1} {#2}
\@@_point_process:nnnnn
{ \@@_point_intersect_lines:nnnnnnnn }
{#1} {#2} {#3} {#4}
}
% \end{macrocode}
% At this stage we have all of the information we need, fully expanded:
% \begin{enumerate}[label = \#\arabic*, font = \ttfamily]
% \item $x_{3}$
% \item $y_{3}$
% \item $x_{4}$
% \item $y_{4}$
% \item $x_{1}$
% \item $y_{1}$
% \item $x_{2}$
% \item $y_{2}$
% \item $x_{3}$
% \item $y_{3}$
% \item $x_{4}$
% \item $y_{4}$
% \end{enumerate}
% so now just have to do all of the calculation.
% \begin{macrocode}
Expand Down Expand Up @@ -529,18 +560,14 @@
% \begin{macrocode}
\cs_new:Npn \draw_point_interpolate_arcaxes:nnnnnn #1#2#3#4#5#6
{
\@@_point_process:nnn
{
\@@_point_process:nn
{ \@@_point_interpolate_arcaxes_auxi:nnnnnnnnn {#1} {#5} {#6} }
{#4}
}
{#2} {#3}
\@@_point_process:nnnn
{ \@@_point_interpolate_arcaxes_auxi:nnnnnnnnn {#1} {#5} {#6} }
{#2} {#3} {#4}
}
\cs_new:Npn \@@_point_interpolate_arcaxes_auxi:nnnnnnnnn #1#2#3#4#5#6#7#8#9
{
\@@_point_interpolate_arcaxes_auxii:fnnnnnnnn
{ \fp_eval:n {#1} } {#2} {#3} {#6} {#7} {#8} {#9} {#4} {#5}
{ \fp_eval:n {#1} } {#2} {#3} {#4} {#5} {#6} {#7} {#8} {#9}
}
% \end{macrocode}
% At this stage, the three co-ordinate pairs are fully expanded but somewhat
Expand Down Expand Up @@ -623,19 +650,15 @@
% \begin{macrocode}
\cs_new:Npn \draw_point_interpolate_curve:nnnnnn #1#2#3#4#5
{
\@@_point_process:nnn
{
\@@_point_process:nnn
{ \@@_point_interpolate_curve_auxi:nnnnnnnnn {#1} }
{#4} {#5}
}
{#2} {#3}
\@@_point_process:nnnnn
{ \@@_point_interpolate_curve_auxi:nnnnnnnnn {#1} }
{#2} {#3} {#4} {#5}
}
\cs_new:Npn \@@_point_interpolate_curve_auxi:nnnnnnnnn #1#2#3#4#5#6#7#8#9
{
\@@_point_interpolate_curve_auxii:fnnnnnnnn
{ \fp_eval:n {#1} }
{#6} {#7} {#8} {#9} {#2} {#3} {#4} {#5}
{#2} {#3} {#4} {#5} {#6} {#7} {#8} {#9}
}
% \end{macrocode}
% At this stage, everything is fully expanded and back in the input order.
Expand Down

0 comments on commit 4b1620b

Please sign in to comment.