diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx index 1eaf1bdeb0f..f9faeada808 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3candidates.dtx @@ -36,7 +36,7 @@ % %<*driver|package> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3candidates.dtx 4521 2013-07-09 11:45:31Z joseph $ +\GetIdInfo$Id: l3candidates.dtx 4576 2013-07-24 21:40:24Z joseph $ {L3 Experimental additions to l3kernel} %</driver|package> %<*driver> @@ -2154,25 +2154,29 @@ % \end{macrocode} % % \begin{macro}[rEXP]{\prop_map_tokens:Nn, \prop_map_tokens:cn} -% \begin{macro}[aux]{\@@_map_tokens:nwn} -% The mapping grabs one key--value pair at a time, and stops when -% reaching the marker key \cs{q_recursion_tail}, which -% cannot appear in normal keys since those are strings. The odd -% construction |\use:n {#1}| allows |#1| to contain any token. +% \begin{macro}[aux]{\@@_map_tokens:nwwn} +% The mapping is very similar to \cs{prop_map_function:NN}. It grabs +% one key--value pair at a time, and stops when reaching the marker +% key \cs{q_recursion_tail}, which cannot appear in normal keys since +% those are strings. The odd construction |\use:n {#1}| allows |#1| +% to contain any token without interfering with \cs{prop_map_break:}. +% Argument |#2| of \cs{@@_map_tokens:nwwn} is empty, with two +% exceptions: it is \cs{s_@@} the first time and \cs{s_obj_end} the +% last. % \begin{macrocode} \cs_new:Npn \prop_map_tokens:Nn #1#2 { - \exp_last_unbraced:Nno \@@_map_tokens:nwn {#2} #1 - \s_@@ \q_recursion_tail \s_@@ { } + \exp_last_unbraced:Nno \@@_map_tokens:nwwn {#2} #1 + \@@_pair:wn \q_recursion_tail \s_@@ { } \__prg_break_point:Nn \prop_map_break: { } } -\cs_new:Npn \@@_map_tokens:nwn #1 \s_@@ #2 \s_@@ #3 +\cs_new:Npn \@@_map_tokens:nwwn #1#2 \@@_pair:wn #3 \s_@@ #4 { - \if_meaning:w \q_recursion_tail #2 + \if_meaning:w \q_recursion_tail #3 \exp_after:wN \prop_map_break: \fi: - \use:n {#1} {#2} {#3} - \@@_map_tokens:nwn {#1} + \use:n {#1} {#3} {#4} + \@@_map_tokens:nwwn {#1} } \cs_generate_variant:Nn \prop_map_tokens:Nn { c } % \end{macrocode} @@ -2180,7 +2184,7 @@ % \end{macro} % % \begin{macro}[EXP]{\prop_get:Nn, \prop_get:cn} -% \begin{macro}[aux, EXP]{\@@_get_Nn:nwn} +% \begin{macro}[aux, EXP]{\@@_get_Nn:nwwn} % Getting the value corresponding to a key in a property list in an % expandable fashion is similar to mapping some tokens. Go through % the property list one \meta{key}--\meta{value} pair at a time: the @@ -2194,15 +2198,15 @@ % \begin{macrocode} \cs_new:Npn \prop_get:Nn #1#2 { - \exp_last_unbraced:Noo \@@_get_Nn:nwn { \tl_to_str:n {#2} } #1 - \s_@@ \tl_to_str:n {#2} \s_@@ { } + \exp_last_unbraced:Noo \@@_get_Nn:nwwn { \tl_to_str:n {#2} } #1 + \@@_pair:wn \tl_to_str:n {#2} \s_@@ { } \__prg_break_point: } -\cs_new:Npn \@@_get_Nn:nwn #1 \s_@@ #2 \s_@@ #3 +\cs_new:Npn \@@_get_Nn:nwwn #1#2 \@@_pair:wn #3 \s_@@ #4 { - \str_if_eq_x:nnTF {#1} {#2} - { \__prg_break:n { \exp_not:n {#3} } } - { \@@_get_Nn:nwn {#1} } + \str_if_eq_x:nnTF {#1} {#3} + { \__prg_break:n { \exp_not:n {#4} } } + { \@@_get_Nn:nwwn {#1} } } \cs_generate_variant:Nn \prop_get:Nn { c } % \end{macrocode} @@ -2216,26 +2220,26 @@ % \end{macrocode} % % \begin{macro}{\seq_item:Nn, \seq_item:cn} -% \begin{macro}[aux]{\@@_item:nnn} +% \begin{macro}[aux]{\@@_item:wNn, \@@_item:nnn} % The idea here is to find the offset of the item from the left, then use % a loop to grab the correct item. If the resulting offset is too large, % then the stop code |{ ? \__prg_break: } { }| will be used by the auxiliary, % terminating the loop and returning nothing at all. % \begin{macrocode} -\cs_new:Npn \seq_item:Nn #1#2 +\cs_new:Npn \seq_item:Nn #1 { \exp_after:wN \@@_item:wNn #1 #1 } +\cs_new:Npn \@@_item:wNn \s_@@ #1 \s_obj_end #2#3 { - \exp_last_unbraced:Nfo \@@_item:nnn + \exp_args:Nf \@@_item:nnn { \int_eval:n { - \int_compare:nNnT {#2} < \c_zero - { \seq_count:N #1 + \c_one + } - #2 + \int_compare:nNnT {#3} < \c_zero + { \seq_count:N #2 + \c_one + } + #3 } } #1 - { ? \__prg_break: } - { } + { ? \__prg_break: } { } \__prg_break_point: } \cs_new:Npn \@@_item:nnn #1#2#3 @@ -2255,34 +2259,33 @@ % \seq_mapthread_function:NNN, \seq_mapthread_function:NcN, % \seq_mapthread_function:cNN, \seq_mapthread_function:ccN % } -% \begin{macro}[aux]{\@@_mapthread_function:NN} +% \begin{macro}[aux] +% {\@@_mapthread_function:wNN, \@@_mapthread_function:wNw} % \begin{macro}[aux]{\@@_mapthread_function:Nnnwnn} -% The idea here is to first expand both of the sequences, adding the usual -% |{ ? \__prg_break: } { }| to the end of each one. This is most conveniently -% done in two steps using an auxiliary function. The mapping then throws -% away the first token of |#2| and |#5|, which for items in the sequences -% will both be \cs{@@_item:n}. The function to be mapped will then be -% applied to the two entries. When the code hits the end of one of the -% sequences, the break material will stop the entire loop and tidy up. This -% avoids needing to find the count of the two sequences, or worrying about -% which is longer. +% The idea here is to first expand both of the sequences, adding the +% usual |{ ? \__prg_break: } { }| to the end of each one. This is +% most conveniently done in two steps using an auxiliary function. +% The mapping then throws away the first tokens of |#2| and |#5|, +% which for items in the sequences will both be \cs{s_@@} +% \cs{@@_item:n}. The function to be mapped will then be applied to +% the two entries. When the code hits the end of one of the +% sequences, the break material will stop the entire loop and tidy up. +% This avoids needing to find the count of the two sequences, or +% worrying about which is longer. % \begin{macrocode} \cs_new:Npn \seq_mapthread_function:NNN #1#2#3 + { \exp_after:wN \@@_mapthread_function:wNN #2 #1 #3 } +\cs_new:Npn \@@_mapthread_function:wNN \s_@@ #1 \s_obj_end #2#3 { - \exp_after:wN \@@_mapthread_function:NN - \exp_after:wN #3 - \exp_after:wN #1 - #2 - { ? \__prg_break: } { } + \exp_after:wN \@@_mapthread_function:wNw #2 #3 + #1 { ? \__prg_break: } { } \__prg_break_point: } -\cs_new:Npn \@@_mapthread_function:NN #1#2 +\cs_new:Npn \@@_mapthread_function:wNw \s_@@ #1 \s_obj_end #2 { - \exp_after:wN \@@_mapthread_function:Nnnwnn - \exp_after:wN #1 - #2 - { ? \__prg_break: } { } - \q_stop + \@@_mapthread_function:Nnnwnn #2 + #1 { ? \__prg_break: } { } + \q_stop } \cs_new:Npn \@@_mapthread_function:Nnnwnn #1#2#3#4 \q_stop #5#6 { @@ -2316,22 +2319,22 @@ \cs_new_protected:Npn \seq_set_from_clist:NN #1#2 { \tl_set:Nx #1 - { \clist_map_function:NN #2 \@@_wrap_item:n } + { \s_@@ \clist_map_function:NN #2 \@@_wrap_item:n \s_obj_end } } \cs_new_protected:Npn \seq_set_from_clist:Nn #1#2 { \tl_set:Nx #1 - { \clist_map_function:nN {#2} \@@_wrap_item:n } + { \s_@@ \clist_map_function:nN {#2} \@@_wrap_item:n \s_obj_end } } \cs_new_protected:Npn \seq_gset_from_clist:NN #1#2 { \tl_gset:Nx #1 - { \clist_map_function:NN #2 \@@_wrap_item:n } + { \s_@@ \clist_map_function:NN #2 \@@_wrap_item:n \s_obj_end } } \cs_new_protected:Npn \seq_gset_from_clist:Nn #1#2 { \tl_gset:Nx #1 - { \clist_map_function:nN {#2} \@@_wrap_item:n } + { \s_@@ \clist_map_function:nN {#2} \@@_wrap_item:n \s_obj_end } } \cs_generate_variant:Nn \seq_set_from_clist:NN { Nc } \cs_generate_variant:Nn \seq_set_from_clist:NN { c , cc } @@ -2347,7 +2350,7 @@ % {\seq_reverse:N, \seq_reverse:c, \seq_greverse:N, \seq_greverse:c} % \begin{macro}[aux]{\@@_tmp:w} % \begin{macro}[aux]{\@@_reverse:NN} -% \begin{macro}[aux]{\@@_reverse_item:nwn} +% \begin{macro}[aux]{\@@_reverse_setup:w, \@@_reverse_item:nwn} % Previously, \cs{seq_reverse:N} was coded by collecting the items % in reverse order after an \cs{exp_stop_f:} marker. % \begin{verbatim} @@ -2389,9 +2392,11 @@ { \cs_set_eq:NN \@@_tmp:w \@@_item:n \cs_set_eq:NN \@@_item:n \@@_reverse_item:nwn - #1 #2 { #2 \exp_not:n { } } + #1 #2 { \exp_after:wN \@@_reverse_setup:w #2 } \cs_set_eq:NN \@@_item:n \@@_tmp:w } +\cs_new:Npn \@@_reverse_setup:w #1 \s_obj_end + { #1 \exp_not:n { } \s_obj_end } \cs_new:Npn \@@_reverse_item:nwn #1 #2 \exp_not:n #3 { #2 @@ -2669,7 +2674,7 @@ { \exp_args:Nf \@@_act_output:n { - \exp_args:NNo \str_case:nnn #2 {#1} + \exp_args:NNo \str_case:nnF #2 {#1} { \exp_stop_f: #2 } } } |