Skip to content

Commit

Permalink
refactor(pgfexpl): Initial macros
Browse files Browse the repository at this point in the history
which are drop-in replacements for expl3 functions

Signed-off-by: muzimuzhi <[email protected]>
  • Loading branch information
muzimuzhi committed Jan 10, 2022
1 parent 5983e00 commit f0ab478
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tex/generic/pgf/math/pgfmathfunctions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
\def\pgfmath@local@function@@body@trimspaces#1,{%
% strip spaces on both sides of #1 in case it starts with a space,
% e.g., #1 is ` \y` which comes from `func(\x, \y)=...;`
\expandafter\pgfmath@local@function@@body\expanded{{\pgfutil@trimspaces@noexp{#1}}}%
\pgfexpl@exp@args@@Ne\pgfmath@local@function@@body{\pgfutil@trimspaces@noexp{#1}}%
}

\def\pgfmath@local@function@@body#1{%
Expand Down
80 changes: 80 additions & 0 deletions tex/generic/pgf/utilities/pgfutil-common-expl.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
% Copyright 2022 by Yukai Chou
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.

%
% This file provides utility commands that are drop-in replacements
% for expl3 macros.
%
% Naming conventions:
% pgf_cs = "pgfexpl@" + expl3_cs.replace("_", "@").replace(":", "@@")
% For example,
% expl3_cs: \exp_args:Ne, \tl_put_right:Nn
% pgf_cs: \pgfexpl@exp@args@@Ne, \pgfexpl@tl@put@right@@Nn


%
% l3basics package
%

% \cs_meaning:c
\long\def\pgfexpl@cs@meaning@@c#1{%
\ifcsname #1\endcsname
\expandafter\pgfutil@firstoftwo
\else
\expandafter\pgfutil@secondoftwo
\fi
{\pgfexpl@exp@args@@Nc\meaning{#1}}
{\detokenize{undefined}}%
}

%
% l3tl package
%

% \tl_if_eq:NNTF
\long\def\pgfexpl@tl@if@eq@@NNTF#1#2{%
\ifx#1#2\pgfexpl@@@prg@TF@true@@w\fi\pgfutil@secondoftwo
}

% \tl_if_eq:ccTF
\long\def\pgfexpl@tl@if@eq@@ccTF{%
\pgfexpl@exp@args@@Ncc\pgfexpl@tl@if@eq@@NNTF
}

% \__prg_TF_true:w
\long\def\pgfexpl@@@prg@TF@true@@w\fi\pgfutil@secondoftwo{%
\fi\pgfutil@firstoftwo
}


%
% l3expan package
%

% \exp_args:Nc
\long\def\pgfexpl@exp@args@@Nc#1#2{%
\expandafter#1\csname #2\endcsname
}

% \exp_args:No
\long\def\pgfexpl@exp@args@@No#1#2{%
\expandafter#1\expandafter{#2}%
}

% \exp_args:Ne
\long\def\pgfexpl@exp@args@@Ne#1#2{%
\expandafter#1\expanded{{#2}}%
}

% \exp_args:Ncc
\long\def\pgfexpl@exp@args@@Ncc#1#2#3{%
\expandafter#1\csname #2\expandafter\endcsname\csname #3\endcsname
}

\endinput
1 change: 1 addition & 0 deletions tex/generic/pgf/utilities/pgfutil-common.tex
Original file line number Diff line number Diff line change
Expand Up @@ -919,5 +919,6 @@
\endgroup
}%
\input pgfutil-common-lists.tex
\input pgfutil-common-expl.tex

\endinput

0 comments on commit f0ab478

Please sign in to comment.