|
33 | 33 | %<*driver>
|
34 | 34 | % \fi
|
35 | 35 | \ProvidesFile{ltsockets.dtx}
|
36 |
| - [2024/10/27 v0.9b LaTeX Kernel (Sockets)] |
| 36 | + [2024/12/27 v0.9c LaTeX Kernel (Sockets)] |
37 | 37 | % \iffalse
|
38 | 38 | %
|
39 | 39 | \documentclass{l3doc}
|
|
645 | 645 | % \cs{LogSocket} and \cs{socket_log:n} only differ in that they don't stop.
|
646 | 646 | % \end{function}
|
647 | 647 | %
|
| 648 | +% |
| 649 | +% It is sometimes necessary/helpful to know if a particular socket or |
| 650 | +% plug exists (or is assigned to a certain socket) and based on that |
| 651 | +% take different actions. |
| 652 | +% |
| 653 | +% \begin{function}[EXP]{\IfSocketExistsTF,\socket_if_exist:nTF} |
| 654 | +% \begin{syntax} |
| 655 | +% \cs{IfSocketExistsTF} \Arg{socket-name} \Arg{true code} \Arg{false code} |
| 656 | +% \end{syntax} |
| 657 | +% If socket \meta{socket-name} exists then execute \meta{true code} |
| 658 | +% otherwise \meta{false code}. Variants with only \texttt{T} or |
| 659 | +% \texttt{F} are also available. |
| 660 | +% \end{function} |
| 661 | +% |
| 662 | +% \begin{function}[EXP]{\IfSocketPlugExistsTF,\socket_if_plug_exist:nnTF} |
| 663 | +% \begin{syntax} |
| 664 | +% \cs{IfSocketPlugExistsTF} \Arg{socket-name} \Arg{plug-name} |
| 665 | +% \qquad \Arg{true code} \Arg{false code} |
| 666 | +% \end{syntax} |
| 667 | +% If plug \meta{plug-name} for socket \meta{socket-name} exists then |
| 668 | +% execute \meta{true code} otherwise \meta{false code}. Variants |
| 669 | +% with only \texttt{T} or \texttt{F} are also available. |
| 670 | +% \end{function} |
| 671 | +% |
| 672 | +% \begin{function}[EXP]{\IfSocketPlugAssignedTF,\socket_if_plug_assigned:nnTF} |
| 673 | +% \begin{syntax} |
| 674 | +% \cs{IfSocketPlugAssignedTF} \Arg{socket-name} \Arg{plug-name} |
| 675 | +% \qquad \Arg{true code} \Arg{false code} |
| 676 | +% \end{syntax} |
| 677 | +% If plug \meta{plug-name} is assigned to socket \meta{socket-name} |
| 678 | +% then execute \meta{true code} otherwise \meta{false |
| 679 | +% code}. Variants with only \texttt{T} or \texttt{F} are also |
| 680 | +% available. |
| 681 | +% \end{function} |
| 682 | +% |
| 683 | +% |
| 684 | +% |
648 | 685 | %
|
649 | 686 | % \begin{function}{\DebugSocketsOn,\DebugSocketsOff,
|
650 | 687 | % \socket_debug_on:,\socket_debug_off:}
|
|
654 | 691 | % Turns debugging of sockets on or off.
|
655 | 692 | % \end{function}
|
656 | 693 | %
|
| 694 | +% |
| 695 | +% |
657 | 696 | % \subsubsection{Rationale for error handling}
|
658 | 697 | %
|
659 | 698 | % The errors during the declarations are produced to help with
|
|
766 | 805 | % does nothing by default other than swallowing its inputs (if any).
|
767 | 806 | % \begin{macrocode}
|
768 | 807 | \cs_new_protected:Npn \socket_new:nn #1 #2 {
|
769 |
| - \str_if_exist:cTF { l_@@_#1_plug_str } |
| 808 | + \socket_if_exist:nTF {#1} |
770 | 809 | {
|
771 | 810 | \msg_error:nnn { socket } { already-declared } {#1}
|
772 | 811 | }
|
|
796 | 835 | }
|
797 | 836 | % \end{macrocode}
|
798 | 837 | % \end{macro}
|
799 |
| -% |
| 838 | +% |
| 839 | +% |
| 840 | +% |
| 841 | +% \begin{macro}[pTF, EXP] { \socket_if_exist:n } |
| 842 | +% Conditional testing the existance of a socket. |
| 843 | +% The argument is fully expanded as part of the csname generation. |
| 844 | +% \changes{v0.9c}{2024/12/27}{Conditionals for sockets, plugs, and |
| 845 | +% assignments (gh/1577)} |
| 846 | +% \begin{macrocode} |
| 847 | +\prg_new_conditional:Npnn \socket_if_exist:n #1 { p , T , F , TF } |
| 848 | + { \str_if_exist:cTF { l_@@_#1_plug_str } |
| 849 | + \prg_return_true: |
| 850 | + \prg_return_false: |
| 851 | + } |
| 852 | +% \end{macrocode} |
| 853 | +% \end{macro} |
| 854 | +% |
800 | 855 | %
|
801 | 856 | % \begin{macro}{\socket_log:n,\socket_show:n}
|
802 | 857 | % Show the current state of the socket --- for now this is just a
|
803 | 858 | % quick draft and should be redone and extended.
|
804 | 859 | % \begin{macrocode}
|
805 | 860 | \cs_new_protected:Npn \socket_log:n #1 {
|
806 | 861 | \typeout{ Socket~ #1:}
|
807 |
| - \str_if_exist:cTF { l_@@_#1_plug_str } |
| 862 | + \socket_if_exist:nTF {#1} |
808 | 863 | {
|
809 | 864 | \typeout{ \@spaces number~ of~ inputs~ =~
|
810 | 865 | \int_use:c { c_@@_#1_args_int } }
|
|
842 | 897 | % the number of arguments from the saved int.
|
843 | 898 | % \begin{macrocode}
|
844 | 899 | \cs_new_protected:Npn \socket_new_plug:nnn #1#2#3 {
|
845 |
| - \str_if_exist:cTF { l_@@_#1_plug_str } |
| 900 | + \socket_if_exist:nTF {#1} |
846 | 901 | {
|
847 |
| - \cs_if_exist:cTF { @@_#1_plug_#2:w } |
| 902 | + \socket_if_plug_exist:nnTF {#1} {#2} |
848 | 903 | {
|
849 | 904 | \msg_error:nnnn { socket } { plug-already-declared } {#1} {#2}
|
850 | 905 | }
|
|
863 | 918 | { Plug~ '#2'~ for~ socket~ '#1'~ declared. }
|
864 | 919 | }
|
865 | 920 | }
|
866 |
| - { |
867 |
| - \msg_error:nnn { socket } { undeclared } {#1} |
868 |
| - } |
| 921 | + { \msg_error:nnn { socket } { undeclared } {#1} } |
869 | 922 | }
|
870 | 923 | % \end{macrocode}
|
871 | 924 | % Changing the plug of an existing socket is rather similar, except
|
872 | 925 | % that we don't have to deal with adding it to the debugging
|
873 | 926 | % sequence.
|
874 | 927 | % \begin{macrocode}
|
875 | 928 | \cs_new_protected:Npn \socket_set_plug:nnn #1#2#3 {
|
876 |
| - \str_if_exist:cTF { l_@@_#1_plug_str } |
| 929 | + \socket_if_exist:nTF {#1} |
877 | 930 | {
|
878 |
| - \cs_if_exist:cTF { @@_#1_plug_#2:w } |
| 931 | + \socket_if_plug_exist:nnTF {#1} {#2} |
879 | 932 | {
|
880 | 933 | \cs_generate_from_arg_count:cNnn
|
881 | 934 | { @@_#1_plug_#2:w }
|
|
889 | 942 | \msg_error:nnnn { socket } { plug-undeclared } {#1} {#2}
|
890 | 943 | }
|
891 | 944 | }
|
892 |
| - { |
893 |
| - \msg_error:nnn { socket } { undeclared } {#1} |
894 |
| - } |
| 945 | + { \msg_error:nnn { socket } { undeclared } {#1} } |
895 | 946 | }
|
896 | 947 | % \end{macrocode}
|
897 | 948 | % \end{macro}
|
898 | 949 | %
|
899 |
| -% |
| 950 | +% |
| 951 | +% |
| 952 | +% \begin{macro}[pTF, EXP] { \socket_if_plug_exist:nn } |
| 953 | +% Conditional testing the existance of a plug. |
| 954 | +% Both arguments are fully expanded as part of the csname generation. |
| 955 | +% \changes{v0.9c}{2024/12/27}{Conditionals for sockets, plugs, and |
| 956 | +% assignments (gh/1577)} |
| 957 | +% \begin{macrocode} |
| 958 | +\prg_new_conditional:Npnn \socket_if_plug_exist:nn #1#2 { p , T , F , TF } |
| 959 | + { \cs_if_exist:cTF { @@_#1_plug_#2:w } |
| 960 | + \prg_return_true: |
| 961 | + \prg_return_false: |
| 962 | + } |
| 963 | +% \end{macrocode} |
| 964 | +% \end{macro} |
| 965 | +% |
| 966 | +% |
900 | 967 | %
|
901 | 968 | % \begin{macro}{\socket_assign_plug:nn}
|
902 | 969 | %
|
903 | 970 | % Assigning a plug to a socket just changes the name in
|
904 | 971 | % the socket string. The assignment is local to the current group.
|
905 | 972 | % \begin{macrocode}
|
906 | 973 | \cs_new_protected:Npn \socket_assign_plug:nn #1 #2 {
|
907 |
| - \str_if_exist:cTF { l_@@_#1_plug_str } |
| 974 | + \socket_if_exist:nTF {#1} |
908 | 975 | {
|
909 |
| - \cs_if_exist:cTF { @@_#1_plug_#2:w } |
| 976 | + \socket_if_plug_exist:nnTF {#1} {#2} |
910 | 977 | {
|
911 | 978 | \@@_debug_term:n
|
912 | 979 | { Replacing~ plug~ '\str_use:c { l_@@_#1_plug_str }'~
|
|
921 | 988 | }
|
922 | 989 | % \end{macrocode}
|
923 | 990 | % \end{macro}
|
924 |
| -% |
| 991 | +% |
| 992 | +% |
| 993 | +% |
| 994 | +% \begin{macro}[pTF, EXP] { \socket_if_plug_assigned:nn } |
| 995 | +% Conditional testing the assignment of a plug. |
| 996 | +% Both arguments are fully expanded. |
| 997 | +% \changes{v0.9c}{2024/12/27}{Conditionals for sockets, plugs, and |
| 998 | +% assignments (gh/1577)} |
| 999 | +% \begin{macrocode} |
| 1000 | +\prg_new_conditional:Npnn \socket_if_plug_assigned:nn #1#2 { p , T , F , TF } |
| 1001 | + { \exp_args:Ne |
| 1002 | + \str_if_eq:nvTF {#2} { l__socket_#1_plug_str } |
| 1003 | + \prg_return_true: |
| 1004 | + \prg_return_false: |
| 1005 | + } |
| 1006 | +% \end{macrocode} |
| 1007 | +% \end{macro} |
| 1008 | +% |
| 1009 | +% |
925 | 1010 | %
|
926 | 1011 | % \begin{macro}{\socket_use:nw,\socket_use:n,\socket_use:nn,\socket_use:nnn,\socket_use:nnnn}
|
927 | 1012 | %
|
|
1044 | 1129 | % \end{macro}
|
1045 | 1130 | %
|
1046 | 1131 | %
|
| 1132 | +% \begin{macro}{\IfSocketExistsTF,\IfSocketExistsT,\IfSocketExistsF, |
| 1133 | +% \IfSocketPlugExistsTF,\IfSocketPlugExistsT, |
| 1134 | +% \IfSocketPlugExistsF, |
| 1135 | +% \IfSocketPlugAssignedTF,\IfSocketPlugAssignedT, |
| 1136 | +% \IfSocketPlugAssignedF} |
| 1137 | +% A bunch of conditionals: |
| 1138 | +% \changes{v0.9c}{2024/12/27}{Conditionals for sockets, plugs, and |
| 1139 | +% assignments (gh/1577)} |
| 1140 | +% \begin{macrocode} |
| 1141 | +\cs_new_eq:NN \IfSocketExistsTF \socket_if_exist:nTF |
| 1142 | +\cs_new_eq:NN \IfSocketExistsT \socket_if_exist:nT |
| 1143 | +\cs_new_eq:NN \IfSocketExistsF \socket_if_exist:nF |
| 1144 | +% \end{macrocode} |
| 1145 | +% |
| 1146 | +% \begin{macrocode} |
| 1147 | +\cs_new_eq:NN \IfSocketPlugExistsTF \socket_if_plug_exist:nnTF |
| 1148 | +\cs_new_eq:NN \IfSocketPlugExistsT \socket_if_plug_exist:nnT |
| 1149 | +\cs_new_eq:NN \IfSocketPlugExistsF \socket_if_plug_exist:nnF |
| 1150 | +% \end{macrocode} |
| 1151 | +% |
| 1152 | +% \begin{macrocode} |
| 1153 | +\cs_new_eq:NN \IfSocketPlugAssignedTF \socket_if_plug_assigned:nnTF |
| 1154 | +\cs_new_eq:NN \IfSocketPlugAssignedT \socket_if_plug_assigned:nnT |
| 1155 | +\cs_new_eq:NN \IfSocketPlugAssignedF \socket_if_plug_assigned:nnF |
| 1156 | +% \end{macrocode} |
| 1157 | +% \end{macro} |
1047 | 1158 | %
|
1048 | 1159 | % \begin{macrocode}
|
1049 | 1160 | %
|
|
1061 | 1172 | %<latexrelease>\let \DebugSocketsOn \@undefined
|
1062 | 1173 | %<latexrelease>\let \DebugSocketsOff \@undefined
|
1063 | 1174 | %<latexrelease>
|
| 1175 | +%<latexrelease>\let \IfSocketExistsTF \@undefined |
| 1176 | +%<latexrelease>\let \IfSocketExistsT \@undefined |
| 1177 | +%<latexrelease>\let \IfSocketExistsF \@undefined |
| 1178 | +%<latexrelease>\let \IfSocketPlugExistsTF \@undefined |
| 1179 | +%<latexrelease>\let \IfSocketPlugExistsT \@undefined |
| 1180 | +%<latexrelease>\let \IfSocketPlugExistsF \@undefined |
| 1181 | +%<latexrelease>\let \IfSocketPlugAssignedTF \@undefined |
| 1182 | +%<latexrelease>\let \IfSocketPlugAssignedT \@undefined |
| 1183 | +%<latexrelease>\let \IfSocketPlugAssignedF \@undefined |
| 1184 | +%<latexrelease> |
1064 | 1185 | %<latexrelease>\EndModuleRelease
|
1065 | 1186 | % \end{macrocode}
|
1066 | 1187 | %
|
|
0 commit comments