diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3prop.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3prop.dtx | 148 |
1 files changed, 75 insertions, 73 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx index edbb4ce3815..0ce5f6b2b20 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3prop.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3prop.dtx Copyright (C) 1990-2017 The LaTeX3 Project +%% File: l3prop.dtx Copyright (C) 1990-2018 The LaTeX3 Project % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -41,7 +41,7 @@ % }^^A % } % -% \date{Released 2018/03/05} +% \date{Released 2018-04-30} % % \maketitle % @@ -447,16 +447,41 @@ % A permanently-empty property list used for internal comparisons. % \end{variable} % -% \section{Internal property list functions} +% \end{documentation} +% +% \begin{implementation} +% +% \section{\pkg{l3prop} implementation} +% +% \TestFiles{m3prop001, m3prop002, m3prop003, m3prop004, m3show001} +% +% \begin{macrocode} +%<*initex|package> +% \end{macrocode} +% +% \begin{macrocode} +%<@@=prop> +% \end{macrocode} +% +% A property list is a macro whose top-level expansion is of the form +% \begin{quote} +% \cs{s_@@} +% \cs{@@_pair:wn} \meta{key_1} \cs{s_@@} \Arg{value_1} \\ +% \ldots{} \\ +% \cs{@@_pair:wn} \meta{key_n} \cs{s_@@} \Arg{value_n} \\ +% \end{quote} +% where \cs{s_@@} is a scan mark +% (equal to \cs{scan_stop:}), and \cs{@@_pair:wn} can be used to map +% through the property list. % -% \begin{variable}{\s__prop} +% \begin{variable}{\s_@@} % The internal token used at the beginning of property lists. This is -% also used after each \meta{key} (see \cs{__prop_pair:wn}). +% also used after each \meta{key} (see \cs{@@_pair:wn}). % \end{variable} % -% \begin{variable}{\__prop_pair:wn} +% \begin{variable}{\@@_pair:wn} % \begin{syntax} -% \cs{__prop_pair:wn} \meta{key} \cs{s__prop} \Arg{item} +% \cs{@@_pair:wn} \meta{key} \cs{s_@@} \Arg{item} % \end{syntax} % The internal token used to begin each key--value pair in the % property list. If expanded outside of a mapping or manipulation @@ -464,14 +489,14 @@ % set globally. % \end{variable} % -% \begin{variable}{\l__prop_internal_tl} +% \begin{variable}{\l_@@_internal_tl} % Token list used to store new key--value pairs to be inserted by % functions of the \cs{prop_put:Nnn} family. % \end{variable} % -% \begin{function}[updated = 2013-01-08]{\__prop_split:NnTF} +% \begin{function}[updated = 2013-01-08]{\@@_split:NnTF} % \begin{syntax} -% \cs{__prop_split:NnTF} \meta{property list} \Arg{key} \Arg{true code} \Arg{false code} +% \cs{@@_split:NnTF} \meta{property list} \Arg{key} \Arg{true code} \Arg{false code} % \end{syntax} % Splits the \meta{property list} at the \meta{key}, giving three % token lists: the \meta{extract} of \meta{property list} before the @@ -495,38 +520,11 @@ % The \meta{key} comparison takes place as described for \cs{str_if_eq:nn}. % \end{function} % -% \end{documentation} -% -% \begin{implementation} -% -% \section{\pkg{l3prop} implementation} -% -% \TestFiles{m3prop001, m3prop002, m3prop003, m3prop004, m3show001} -% -% \begin{macrocode} -%<*initex|package> -% \end{macrocode} -% -% \begin{macrocode} -%<@@=prop> -% \end{macrocode} -% -% A property list is a macro whose top-level expansion is of the form -% \begin{quote} -% \cs{s_@@} -% \cs{@@_pair:wn} \meta{key_1} \cs{s_@@} \Arg{value_1} \\ -% \ldots{} \\ -% \cs{@@_pair:wn} \meta{key_n} \cs{s_@@} \Arg{value_n} \\ -% \end{quote} -% where \cs{s_@@} is a scan mark -% (equal to \cs{scan_stop:}), and \cs{@@_pair:wn} can be used to map -% through the property list. -% % \begin{macro}{\s_@@} % A private scan mark is used as a marker after each key, and at the % very beginning of the property list. % \begin{macrocode} -\__scan_new:N \s_@@ +\scan_new:N \s_@@ % \end{macrocode} % \end{macro} % @@ -561,7 +559,7 @@ % \begin{macrocode} \cs_new_protected:Npn \prop_new:N #1 { - \__chk_if_free_cs:N #1 + \__kernel_chk_if_free_cs:N #1 \cs_gset_eq:NN #1 \c_empty_prop } \cs_generate_variant:Nn \prop_new:N { c } @@ -634,14 +632,15 @@ % \@@_from_keyval:n, % \@@_from_keyval_loop:w, % \@@_from_keyval_split:Nw, +% \@@_from_keyval_key:n, % \@@_from_keyval_key:w, +% \@@_from_keyval_value:n, % \@@_from_keyval_value:w % } % Loop through items separated by commas, with \cs{q_mark} to avoid % losing braces. After checking for termination, split the item at % the first then at the second |=| (which ought to be the first of the -% trailing~|=|). At both splits, trim spaces (the internal -% \cs{__tl_trim_spaces:nn} expects the \cs{q_mark} we give it) and +% trailing~|=|). At both splits, trim spaces and % call \cs{@@_from_keyval_key:w}, then \cs{@@_from_keyval_value:w}, % followed by the trimmed material, \cs{q_nil}, the subsequent part of % the item, and the trailing |=|'s and \cs{q_stop}. After finding the @@ -670,20 +669,24 @@ \cs_new:Npn \@@_from_keyval_loop:w #1 , { \quark_if_recursion_tail_stop:o { \use_none:n #1 } - \@@_from_keyval_split:Nw \@@_from_keyval_key:w + \@@_from_keyval_split:Nw \@@_from_keyval_key:n #1 = = \q_stop { \use_none:n #1 } \@@_from_keyval_loop:w \q_mark } \cs_new:Npn \@@_from_keyval_split:Nw #1#2 = { - \__tl_trim_spaces:nn {#2} - { \exp_last_unbraced:No #1 } \q_nil + \tl_trim_spaces_apply:oN { \use_none:n #2 } #1 + \q_nil } +\cs_new:Npn \@@_from_keyval_key:n #1 + { \@@_from_keyval_key:w #1 } \cs_new:Npn \@@_from_keyval_key:w #1 \q_nil #2 \q_stop { - \@@_from_keyval_split:Nw \@@_from_keyval_value:w + \@@_from_keyval_split:Nw \@@_from_keyval_value:n \q_mark #2 \q_stop {#1} } +\cs_new:Npn \@@_from_keyval_value:n #1 + { \@@_from_keyval_value:w #1 } \cs_new:Npn \@@_from_keyval_value:w #1 \q_nil #2 \q_stop #3#4 { \tl_if_empty:nF { #3 #1 #2 } @@ -694,8 +697,9 @@ \s_@@ { \exp_not:n {#1} } } { - \exp_args:Nnno \__kernel_msg_expandable_error:nnn - { kernel } { prop-keyval } {#4} + \__kernel_msg_expandable_error:nnf + { kernel } { prop-keyval } + { \exp_after:wN \exp_stop_f: #4 } } } } @@ -853,12 +857,12 @@ { \exp_last_unbraced:Noo \@@_item_Nn:nwwn { \tl_to_str:n {#2} } #1 \@@_pair:wn \tl_to_str:n {#2} \s_@@ { } - \__prg_break_point: + \prg_break_point: } \cs_new:Npn \@@_item_Nn:nwwn #1#2 \@@_pair:wn #3 \s_@@ #4 { \str_if_eq_x:nnTF {#1} {#3} - { \__prg_break:n { \exp_not:n {#4} } } + { \prg_break:n { \exp_not:n {#4} } } { \@@_item_Nn:nwwn {#1} } } \cs_generate_variant:Nn \prop_item:Nn { c } @@ -1050,7 +1054,7 @@ \exp_last_unbraced:Noo \@@_if_in:nwwn { \tl_to_str:n {#2} } #1 \@@_pair:wn \tl_to_str:n {#2} \s_@@ { } \q_recursion_tail - \__prg_break_point: + \prg_break_point: } \cs_new:Npn \@@_if_in:nwwn #1#2 \@@_pair:wn #3 \s_@@ #4 { @@ -1065,7 +1069,7 @@ \else: \prg_return_true: \fi: - \__prg_break: + \prg_break: } \prg_generate_conditional_variant:Nnn \prop_if_in:Nn { NV , No , c , cV , co } { p , T , F , TF } @@ -1106,24 +1110,22 @@ % \prop_map_function:cN, \prop_map_function:cc % } % \begin{macro}{\@@_map_function:Nwwn} -% The fastest way to do a recursion here is to use an -% \cs{if_meaning:w} test: the keys are strings, and thus cannot match -% the marker \cs{q_recursion_tail}. A special case to note is when -% the key~|#3| is empty: then \cs{q_recursion_tail} is compared to -% \cs{exp_after:wN}, also different. Note that |#2|~is empty, except -% at the first iteration, where it is \cs{s_@@}. +% The argument delimited by \cs{@@_pair:wn} is empty except at the end +% of the loop where it is \cs{prg_break:}. No need for any quark +% test. % \begin{macrocode} \cs_new:Npn \prop_map_function:NN #1#2 { - \exp_last_unbraced:NNo \@@_map_function:Nwwn #2 #1 - \@@_pair:wn \q_recursion_tail \s_@@ { } - \__prg_break_point:Nn \prop_map_break: { } + \exp_after:wN \use_i_ii:nnn + \exp_after:wN \@@_map_function:Nwwn + \exp_after:wN #2 + #1 + \prg_break: \@@_pair:wn \s_@@ { } \prg_break_point: + \prg_break_point:Nn \prop_map_break: { } } \cs_new:Npn \@@_map_function:Nwwn #1#2 \@@_pair:wn #3 \s_@@ #4 { - \if_meaning:w \q_recursion_tail #3 - \exp_after:wN \prop_map_break: - \fi: + #2 #1 {#3} {#4} \@@_map_function:Nwwn #1 } @@ -1145,15 +1147,15 @@ \cs_new_protected:Npn \prop_map_inline:Nn #1#2 { \cs_gset_eq:cN - { __prg_map_ \int_use:N \g__prg_map_int :wn } \@@_pair:wn - \int_gincr:N \g__prg_map_int + { @@_map_ \int_use:N \g__kernel_prg_map_int :wn } \@@_pair:wn + \int_gincr:N \g__kernel_prg_map_int \cs_gset_protected:Npn \@@_pair:wn ##1 \s_@@ ##2 {#2} #1 - \__prg_break_point:Nn \prop_map_break: + \prg_break_point:Nn \prop_map_break: { - \int_gdecr:N \g__prg_map_int + \int_gdecr:N \g__kernel_prg_map_int \cs_gset_eq:Nc \@@_pair:wn - { __prg_map_ \int_use:N \g__prg_map_int :wn } + { @@_map_ \int_use:N \g__kernel_prg_map_int :wn } } } \cs_generate_variant:Nn \prop_map_inline:Nn { c } @@ -1162,12 +1164,12 @@ % % \begin{macro}[tested = m3prop003]{\prop_map_break:} % \begin{macro}[tested = m3prop003]{\prop_map_break:n} -% The break statements are based on the general \cs{__prg_map_break:Nn}. +% The break statements are based on the general \cs{prg_map_break:Nn}. % \begin{macrocode} \cs_new:Npn \prop_map_break: - { \__prg_map_break:Nn \prop_map_break: { } } + { \prg_map_break:Nn \prop_map_break: { } } \cs_new:Npn \prop_map_break:n - { \__prg_map_break:Nn \prop_map_break: } + { \prg_map_break:Nn \prop_map_break: } % \end{macrocode} % \end{macro} % \end{macro} @@ -1176,7 +1178,7 @@ % % \begin{macro}[tested = m3show001] % {\prop_show:N, \prop_show:c, \prop_log:N, \prop_log:c} -% Apply the general \cs{__kernel_check_defined:NT} and +% Apply the general \cs{__kernel_chk_defined:NT} and % \cs{msg_show:nnnnnn}. Contrarily to sequences and comma lists, % we use \cs{msg_show_item:nn} to format both the key and the value % for each pair. @@ -1187,7 +1189,7 @@ \cs_generate_variant:Nn \prop_log:N { c } \cs_new_protected:Npn \@@_show:NN #1#2 { - \__kernel_check_defined:NT #2 + \__kernel_chk_defined:NT #2 { #1 { LaTeX/kernel } { show-prop } { \token_to_str:N #2 } |