Skip to content

Commit

Permalink
Make \int_value:w public (again)
Browse files Browse the repository at this point in the history
This is sufficiently widely-used that we can't hope
to keep it 'team only', and don't want loads of copies
of the primitive.
  • Loading branch information
josephwright committed Mar 27, 2018
1 parent 71aa488 commit ab09ca1
Show file tree
Hide file tree
Showing 33 changed files with 461 additions and 530 deletions.
8 changes: 4 additions & 4 deletions l3kernel/l3basics.dtx
Expand Up @@ -1341,7 +1341,7 @@
% \begin{quote}
% \cs{__kernel_patch_args:nNNpn} |{ { (#1) } }| \\
% \cs{cs_new:Npn} \cs{int_eval:n} |#1| \\
% ~~|{ \__int_value:w \__int_eval:w #1 \__int_eval_end: }|
% ~~|{ \int_value:w \__int_eval:w #1 \__int_eval_end: }|
% \end{quote}
% would replace |#1| by |(#1)| in the definition of \cs{int_eval:n} when
% debugging is enabled. This fails if the \meta{code} contains~|##|.
Expand Down Expand Up @@ -2038,7 +2038,7 @@
{
\tex_romannumeral:D - 0
\exp_after:wN \use_none:n
\__int_value:w #3 #2 #1 \scan_stop:
\int_value:w #3 #2 #1 \scan_stop:
}
{
\__kernel_msg_expandable_error:nnnn
Expand Down Expand Up @@ -2659,7 +2659,7 @@
% \cs{token_to_str:N}, and stops the \cs{tex_romannumeral:D} with \cs{c_zero}.
% The last case is that the escape character is itself a space. In this
% case, the \cs{if:w} test is true, and the auxiliary \cs{@@_to_str:w}
% comes into play, inserting |-\__int_value:w|, which expands \cs{c_zero}
% comes into play, inserting |-\int_value:w|, which expands \cs{c_zero}
% to the character |0|. The initial \cs{tex_romannumeral:D} then sees
% |0|, which is not a terminated number, followed by the escape character,
% a space, which is removed, terminating the expansion of
Expand All @@ -2682,7 +2682,7 @@
}
\cs_set:Npn \@@_to_str:N #1 { \c_zero }
\cs_set:Npn \@@_to_str:w #1 \@@_to_str:N
{ - \__int_value:w \fi: \exp_after:wN \c_zero }
{ - \int_value:w \fi: \exp_after:wN \c_zero }
% \end{macrocode}
% If speed is a concern we could use \tn{csstring} in \LuaTeX{}. For
% the empty csname that primitive gives an empty result while the
Expand Down
10 changes: 5 additions & 5 deletions l3kernel/l3candidates.dtx
Expand Up @@ -2168,7 +2168,7 @@
\int_compare:nNnF {#1} > 1
{ \use_i_delimit_by_q_stop:nw { \exp_not:n { {#2} {#3} } } }
\exp_after:wN \@@_rand_item:w
\__int_value:w \int_eval:n { #1 - 1 } \s_@@
\int_value:w \int_eval:n { #1 - 1 } \s_@@
}
% \end{macrocode}
% \end{macro}
Expand Down Expand Up @@ -4155,14 +4155,14 @@
\exp_after:wN { \exp_after:wN }
\fi:
\exp_after:wN #3
\__int_value:w \__int_eval:w #2 - #1 \exp_after:wN ;
\int_value:w \__int_eval:w #2 - #1 \exp_after:wN ;
\exp_after:wN { \exp:w \@@_range_skip:w #1 ; { } #4 }
}
\cs_new:Npn \@@_range_skip:w #1 ; #2
{
\if_int_compare:w #1 > 0 \exp_stop_f:
\exp_after:wN \@@_range_skip:w
\__int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\else:
\exp_after:wN \exp_end:
\fi:
Expand All @@ -4175,15 +4175,15 @@
{
\if_int_compare:w #1 > 1 \exp_stop_f:
\exp_after:wN \@@_range_collect_braced:w
\__int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\fi:
{ #2 {#3} }
}
\cs_new:Npn \@@_range_collect_unbraced:w #1 ; #2#3
{
\if_int_compare:w #1 > 1 \exp_stop_f:
\exp_after:wN \@@_range_collect_unbraced:w
\__int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\int_value:w \__int_eval:w #1 - 1 \exp_after:wN ;
\fi:
{ #2 #3 }
}
Expand Down
4 changes: 2 additions & 2 deletions l3kernel/l3file.dtx
Expand Up @@ -2115,7 +2115,7 @@
\tex_edef:D \l_@@_line_part_tl { \if_false: } \fi:
#1
\exp_after:wN \@@_wrap_line_loop:w
\__int_value:w \__int_eval:w
\int_value:w \__int_eval:w
}
\cs_new:Npn \@@_wrap_line_loop:w #1 ; #2#3#4#5#6#7#8#9
{
Expand All @@ -2124,7 +2124,7 @@
\fi:
#2 #3 #4 #5 #6 #7 #8 #9
\exp_after:wN \@@_wrap_line_loop:w
\__int_value:w \__int_eval:w #1 - 8 ;
\int_value:w \__int_eval:w #1 - 8 ;
}
\cs_new:Npn \@@_wrap_line_aux:Nw #1#2#3 \exp_after:wN #4 ;
{
Expand Down
6 changes: 3 additions & 3 deletions l3kernel/l3flag.dtx
Expand Up @@ -204,7 +204,7 @@
\if_cs_exist:w flag~#2~#1 \cs_end:
\cs_set_eq:cN { flag~#2~#1 } \tex_undefined:D
\exp_after:wN \@@_clear:wn
\__int_value:w \__int_eval:w 1 + #1
\int_value:w \__int_eval:w 1 + #1
\else:
\use_i:nnn
\fi:
Expand Down Expand Up @@ -300,7 +300,7 @@
\cs_new:Npn \@@_height_loop:wn #1 ; #2
{
\if_cs_exist:w flag~#2~#1 \cs_end:
\exp_after:wN \@@_height_loop:wn \__int_value:w \__int_eval:w 1 +
\exp_after:wN \@@_height_loop:wn \int_value:w \__int_eval:w 1 +
\else:
\exp_after:wN \@@_height_end:wn
\fi:
Expand All @@ -317,7 +317,7 @@
\cs_new:Npn \flag_raise:n #1
{
\cs:w flag~#1 \exp_after:wN \cs_end:
\__int_value:w \flag_height:n {#1} ;
\int_value:w \flag_height:n {#1} ;
}
% \end{macrocode}
% \end{macro}
Expand Down
29 changes: 14 additions & 15 deletions l3kernel/l3fp-aux.dtx
Expand Up @@ -66,7 +66,7 @@
% \subsection{Access to primitives}
%
% \begin{macro}
% {\@@_int_eval:w,\@@_int_eval_end:, \@@_int_to_roman:w, \@@_int_value:w}
% {\@@_int_eval:w,\@@_int_eval_end:, \@@_int_to_roman:w}
% Largely for performance reasons, we need to directly access primitives
% rather than use \cs{int_eval:n}. This happens \emph{a lot}, so we
% use private names. The same is true for \tn{romannumeral}, although it
Expand All @@ -75,7 +75,6 @@
\cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
\cs_new_eq:NN \@@_int_eval_end: \scan_stop:
\cs_new_eq:NN \@@_int_to_roman:w \tex_romannumeral:D
\cs_new_eq:NN \@@_int_value:w \tex_number:D
% \end{macrocode}
% \end{macro}
%
Expand Down Expand Up @@ -360,7 +359,7 @@
% \end{macro}
%
% \begin{macro}[EXP]{\@@_neg_sign:N}
% When appearing in an integer expression or after \cs{@@_int_value:w},
% When appearing in an integer expression or after \cs{int_value:w},
% this expands to the sign opposite to |#1|, namely $0$ (positive) is
% turned to $2$ (negative), $1$ (\texttt{nan}) to $1$, and $2$ to $0$.
% \begin{macrocode}
Expand Down Expand Up @@ -470,11 +469,11 @@
{
\exp_after:wN \@@_exp_after_normal:Nwwwww
\exp_after:wN #2
\@@_int_value:w #3 \exp_after:wN ;
\@@_int_value:w 1 #4 \exp_after:wN ;
\@@_int_value:w 1 #5 \exp_after:wN ;
\@@_int_value:w 1 #6 \exp_after:wN ;
\@@_int_value:w 1 #7 \exp_after:wN ; #1
\int_value:w #3 \exp_after:wN ;
\int_value:w 1 #4 \exp_after:wN ;
\int_value:w 1 #5 \exp_after:wN ;
\int_value:w 1 #6 \exp_after:wN ;
\int_value:w 1 #7 \exp_after:wN ; #1
}
\cs_new:Npn \@@_exp_after_normal:Nwwwww
#1 #2; 1 #3 ; 1 #4 ; 1 #5 ; 1 #6 ;
Expand Down Expand Up @@ -513,7 +512,7 @@
{ \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w {#1} ; }
\cs_new:Npn \@@_tuple_count:w \s_@@_tuple \@@_tuple_chk:w #1 ;
{
\@@_int_value:w \@@_int_eval:w 0
\int_value:w \@@_int_eval:w 0
\@@_tuple_count_loop:Nw #1 { ? \__prg_break: } ;
\__prg_break_point:
\@@_int_eval_end:
Expand Down Expand Up @@ -709,11 +708,11 @@
% \__fp_int_value:w \__fp_int_eval:w 5 0000 0000
% + 12345 * 8899 ;
% \end{verbatim}
% The \cs{exp_after:wN} triggers \cs{@@_int_value:w} \cs{@@_int_eval:w}, which
% The \cs{exp_after:wN} triggers \cs{int_value:w} \cs{@@_int_eval:w}, which
% starts a first computation, whose initial value is $- 5\,0000$ (the
% \enquote{leading shift}). In that computation appears an
% \cs{exp_after:wN}, which triggers the nested computation
% \cs{@@_int_value:w} \cs{@@_int_eval:w} with starting value $4\,9995\,0000$ (the
% \cs{int_value:w} \cs{@@_int_eval:w} with starting value $4\,9995\,0000$ (the
% \enquote{middle shift}). That, in turn, expands \cs{exp_after:wN}
% which triggers the third computation. The third computation's value
% is $5\,0000\,0000 + 12345 \times 8899$, which has $9$ digits. Adding
Expand Down Expand Up @@ -986,7 +985,7 @@
\cs_new:cpn { @@_decimate_ #1 :Nnnnn } ##1 ##2##3##4##5
{
\exp_after:wN ##1
\@@_int_value:w
\int_value:w
\exp_after:wN \@@_round_digit:Nw #2 ;
\@@_decimate_pack:nnnnnnnnnnw #3 ;
}
Expand All @@ -1012,7 +1011,7 @@
%
% \begin{macro}[EXP]{\@@_decimate_pack:nnnnnnnnnnw}
% The computation of the \meta{rounding} digit leaves an unfinished
% \cs{@@_int_value:w}, which expands the following functions. This
% \cs{int_value:w}, which expands the following functions. This
% allows us to repack nicely the digits we keep. Those digits come
% as an alternation of unbraced and braced blocks of $4$ digits,
% such that the first $5$ groups of token consist in $4$ single digits,
Expand Down Expand Up @@ -1176,7 +1175,7 @@
\or:
\@@_case_return:nw
{
\exp_after:wN \@@_small_int_true:wTF \@@_int_value:w
\exp_after:wN \@@_small_int_true:wTF \int_value:w
\if_meaning:w 2 #2 - \fi: 1 0000 0000 ;
}
\else: \@@_case_return:nw \use_ii:nn
Expand All @@ -1194,7 +1193,7 @@
{
\if_meaning:w 0 #1
\exp_after:wN \@@_small_int_true:wTF
\@@_int_value:w \if_meaning:w 2 #5 - \fi:
\int_value:w \if_meaning:w 2 #5 - \fi:
\if_int_compare:w #2 > 0 \exp_stop_f:
1 0000 0000
\else:
Expand Down

0 comments on commit ab09ca1

Please sign in to comment.