Skip to content

Commit

Permalink
Move part of l3fp-types to kernel
Browse files Browse the repository at this point in the history
This holds the parts that will be needed for
variable and fn support, but not the rest.
  • Loading branch information
josephwright committed Jul 5, 2023
1 parent 49e4447 commit 80c8e7d
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 143 deletions.
1 change: 1 addition & 0 deletions l3kernel/doc/source3body.tex
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ \part{Data types}
l3fp-trig.dtx ,
l3fp-convert.dtx ,
l3fp-random.dtx ,
l3fp-types.dtx
}
\ExplSyntaxOff

Expand Down
1 change: 1 addition & 0 deletions l3kernel/l3.ins
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ and all files in that bundle must be distributed together.
\from{l3fp-trig.dtx} {package}
\from{l3fp-convert.dtx} {package}
\from{l3fp-random.dtx} {package}
\from{l3fp-types.dtx} {package}
\from{l3fparray.dtx} {package}
\from{l3cctab.dtx} {package}
\from{l3sort.dtx} {package}
Expand Down
15 changes: 13 additions & 2 deletions l3kernel/l3fp-logic.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
% \end{macro}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_compare_back_any:ww, \@@_compare_back:ww, \@@_compare_nan:w}
% \begin{macro}[EXP]{\@@_compare_back:ww, \@@_bcmp:ww, \@@_compare_back_any:ww, \@@_compare_nan:w}
% \begin{quote}
% \cs{@@_compare_back_any:ww} \meta{y} |;| \meta{x} |;|
% \end{quote}
Expand All @@ -178,6 +178,17 @@
% a different type, the highest type is a larger number. Finally, if
% $y\leq 0$, then $x>y$, unless both are zero.
% \begin{macrocode}
\cs_new:Npn \@@_compare_back:ww #1#2; #3#4;
{
\cs:w
@@
\@@_type_from_scan:N #1
_bcmp
\@@_type_from_scan:N #3
:ww
\cs_end:
#1#2; #3#4;
}
\cs_new:Npn \@@_compare_back_any:ww #1#2; #3
{
\@@_if_type_fp:NTwFw
Expand All @@ -195,7 +206,7 @@
}
#1#2 ; #3
}
\cs_new:Npn \@@_compare_back:ww
\cs_new:Npn \@@_bcmp:ww
\s_@@ \@@_chk:w #1 #2 #3;
\s_@@ \@@_chk:w #4 #5 #6;
{
Expand Down
184 changes: 184 additions & 0 deletions l3kernel/l3fp-types.dtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
% \iffalse
%
%% File l3fp-types.dtx (C) Copyright 2012-2015,2017,2018,2020,2021,2023 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% http://www.latex-project.org/lppl.txt
%
% This file is part of the "l3kernel bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
% https://github.com/latex3/latex3
%
% for those people who are interested.
%
%<*driver>
\documentclass[full]{l3doc}
\usepackage{amsmath}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \title{^^A
% The \pkg{l3fp-types} package\\ Floating point types^^A
% }
%
% \author{^^A
% The \LaTeX{} Project\thanks
% {^^A
% E-mail:
% \href{mailto:latex-team@latex-project.org}
% {latex-team@latex-project.org}^^A
% }^^A
% }
%
% \date{Released 2018-04-30}
%
% \maketitle
%
% \begin{documentation}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{l3fp-types} implementation}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \begin{macrocode}
%<@@=fp>
% \end{macrocode}
%
% \subsection{Support for types}
%
% Despite lack of documentation, the \pkg{l3fp} internals support types.
% Each additional type must define
% \begin{itemize}
% \item |\s__fp_|\meta{type} and |\__fp_|\meta{type}|_chk:w|;
% \item |\__fp_exp_after_|\meta{type}|_f:nw|;
% \item |\__fp_|\meta{type}|_to_|\meta{out}|:w| for \meta{out} among
% |decimal|, |scientific|, |tl|;
% \end{itemize}
% and may define
% \begin{itemize}
% \item |\__fp_|\meta{type}|_to_int:w| and |\__fp_|\meta{type}|_to_dim:w|;
% \item |\__fp_|\meta{op}|_|\meta{type}|_o:w| for any of the \meta{op}
% that the type implements, among |acos|, |acsc|, |asec|, |asin|,
% |cos|, |cot|, |csc|, |exp|, |ln|, |not|, |sec|, |set_sign|, |sin|,
% |tan|;
% \item |\__fp_|\meta{type_1}|_|\meta{op}|_|\meta{type_2}|_o:ww| for
% \meta{op} among |^*/-+&|\verb"|" and for every pair of types;
% \item |\__fp_|\meta{type_1}|_bcmp_|\meta{type_2}|:ww| for every
% pair of types.
% \end{itemize}
% The latter is set up in \pkg{l3fp-logic}.
%
% \subsection{Dispatch according to the type}
%
% \begin{macro}[EXP]
% {\@@_types_cs_to_op:N, \@@_types_cs_to_op_auxi:wwwn}
% From |\__fp_|\meta{op}|_o:w| produce \meta{op}, otherwise~|?|.
% \begin{macrocode}
\cs_new:Npx \@@_types_cs_to_op:N #1
{
\exp_not:N \exp_after:wN \exp_not:N \@@_types_cs_to_op_auxi:wwwn
\exp_not:N \token_to_str:N #1 \s_@@_mark
\exp_not:N \@@_use_i_delimit_by_s_stop:nw
\tl_to_str:n { @@_ _o:w } \s_@@_mark
{ \exp_not:N \@@_use_i_delimit_by_s_stop:nw ? }
\s_@@_stop
}
\use:x
{
\cs_new:Npn \exp_not:N \@@_types_cs_to_op_auxi:wwwn
##1 \tl_to_str:n { @@_ } ##2
\tl_to_str:n { _o:w } ##3 \s_@@_mark ##4 { ##4 {##2} }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_types_unary:NNw}
% \begin{macro}[EXP]
% {\@@_types_unary_auxi:nNw, \@@_types_unary_auxii:NnNw}
% \begin{syntax}
% \cs{@@_types_unary:NNw} |\__fp_|\meta{function}|_o:w|
% ~~\meta{token} \meta{operand} |@|
% \end{syntax}
% \begin{macrocode}
\cs_new:Npn \@@_types_unary:NNw #1
{
\exp_args:Nf \@@_types_unary_auxi:nNw
{ \@@_types_cs_to_op:N #1 }
}
\cs_new:Npn \@@_types_unary_auxi:nNw #1#2#3
{
\exp_after:wN \@@_types_unary_auxii:NnNw
\cs:w @@_#1 \@@_type_from_scan:N #3 _o:w \cs_end:
{#1}
#2#3
}
\cs_new:Npn \@@_types_unary_auxii:NnNw #1#2#3
{
\token_if_eq_meaning:NNTF \scan_stop: #1
{ \@@_invalid_operation_o:nw {#2} }
{ #1 #3 }
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}[EXP]{\@@_types_binary:Nww}
% \begin{macro}[EXP]
% {\@@_types_binary_auxi:Nww, \@@_types_binary_auxii:NNww}
% \begin{syntax}
% \cs{@@_types_binary:Nww} |\__fp_|\meta{binop}|_o:ww|
% ~~\meta{operand_1} \meta{operand_2} |@|
% \end{syntax}
% \begin{macrocode}
\cs_new:Npn \@@_types_binary:Nww #1
{
\exp_last_unbraced:Nf \@@_types_binary_auxi:Nww
{ \@@_types_cs_to_op:N #1 }
}
\cs_new:Npn \@@_types_binary_auxi:Nww #1#2#3; #4#5; @
{
\exp_after:wN \@@_types_binary_auxii:NNww
\cs:w
@@
\@@_type_from_scan:N #2
_#1
\@@_type_from_scan:N #4
_o:ww
\cs_end:
#1 #2#3; #4#5;
}
\cs_new:Npn \@@_types_binary_auxii:NNww #1#2
{
\token_if_eq_meaning:NNTF \scan_stop: #1
{ \@@_invalid_operation_o:Nww #2 }
{#1}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
4 changes: 2 additions & 2 deletions l3trial/l3fp-extras/l3fp-extras.ins
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\iffalse meta-comment

File l3fp-extras.ins Copyright (C) 201,2021 The LaTeX Project
File l3fp-extras.ins Copyright (C) 201,2021,2023 The LaTeX Project

It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
Expand Down Expand Up @@ -40,7 +40,7 @@ Do not distribute a modified version of this file.
\file{l3fp-extras.sty}%
{%
\from{l3fp-extras.dtx}{package}%
\from{l3fp-types.dtx}{package}%
\from{l3fp-types-extras.dtx}{package}%
\from{l3fp-symbolic.dtx}{package}%
\from{l3fp-functions.dtx}{package}%
\from{l3fp-interchange.dtx}{package}%
Expand Down

0 comments on commit 80c8e7d

Please sign in to comment.