diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-10-31 00:09:22 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-10-31 00:09:22 +0100 |
commit | 7043cd3b7046f6a11112a5d49c4ae5e2dc0c6896 (patch) | |
tree | 92ffcd258fb29e37b4a136eb071fbfd0717be29e /tex/context/base/mkiv/mult-aux.mkxl | |
parent | a0270f13065d116355a953c6f246cbba26289fc2 (diff) | |
download | context-7043cd3b7046f6a11112a5d49c4ae5e2dc0c6896.tar.gz |
2020-10-30 22:27:00
Diffstat (limited to 'tex/context/base/mkiv/mult-aux.mkxl')
-rw-r--r-- | tex/context/base/mkiv/mult-aux.mkxl | 671 |
1 files changed, 254 insertions, 417 deletions
diff --git a/tex/context/base/mkiv/mult-aux.mkxl b/tex/context/base/mkiv/mult-aux.mkxl index 1df5bcf24..c1c99edbd 100644 --- a/tex/context/base/mkiv/mult-aux.mkxl +++ b/tex/context/base/mkiv/mult-aux.mkxl @@ -21,7 +21,7 @@ \unprotect -\edef\??empty{\Uchar25} \letvalue{\Uchar25}\empty % hex 19 +\immutable\edef\??empty{\Uchar25} \immutable\letvalue{\Uchar25}\empty % hex 19 % \edef\s!parent{\Uchar29} % inlining is ugly, a tiny bit faster, but neglectable on a run @@ -174,26 +174,17 @@ \let\m_mult_interfaces_namespace\empty -\def\mult_interfaces_get_parameters#1[#2% - {\if\noexpand#2]% - \expandafter\gobbleoneargument - \else - \def\m_mult_interfaces_namespace{#1}% - \expandafter\mult_interfaces_get_parameters_indeed - \fi#2} +\def\mult_interfaces_get_parameters#1[% + {\def\m_mult_interfaces_namespace{#1}% + \futureexpandis]\gobbleoneargument\mult_interfaces_get_parameters_indeed} -\def\mult_interfaces_get_parameters_indeed#1]% namespace already set +\def\mult_interfaces_get_parameters_indeed#1]% {\mult_interfaces_get_parameters_item#1\ignorearguments\ignorearguments} -\def\mult_interfaces_get_parameters_item_next - {\expandafterspaces\mult_interfaces_get_parameters_item} - -\def\mult_interfaces_get_parameters_item#1,% - {\ifarguments - % done - \else +\def\mult_interfaces_get_parameters_item#*#1,% + {\ifarguments \else \mult_interfaces_get_parameters_item_okay#1,\ignorearguments - \expandafter\mult_interfaces_get_parameters_item_next + \expandafter\mult_interfaces_get_parameters_item \fi} \def\mult_interfaces_get_parameters_item_okay#1=#2,% @@ -219,25 +210,16 @@ \or \mult_interfaces_get_parameters_item_error \else - \expandafter\def\csname\m_mult_interfaces_namespace#1\endcsname{#2}% + \defcsname\m_mult_interfaces_namespace#1\endcsname{#2}% \fi} -% \def\mult_interfaces_get_parameters_item_error#0\csname#2#3\endcsname#0% -% {\if,#3\else\mult_interfaces_get_parameters_error_indeed{#2}{#3}\fi} - - \def\mult_interfaces_get_parameters_item_error#-\csname#1#2\endcsname#-% + \def\mult_interfaces_get_parameters_item_error#-\defcsname#1#2\endcsname#-% {\if,#2\else\mult_interfaces_get_parameters_error_indeed{#1}{#2}\fi} \stopinterface %D Used? -% \def\mult_check_for_assignment_indeed#0=#2#0^^^^0004% -% {\if#2^^^^0003\assignmentfalse\else\assignmenttrue\fi} -% -% \def\mult_check_for_assignment_indeed_begin_#0=#2#0^^^^0004% -% {\if#2^^^^0003} - \def\mult_check_for_assignment_indeed#-=#1#-^^^^0004% {\if#1^^^^0003\assignmentfalse\else\assignmenttrue\fi} @@ -258,20 +240,13 @@ %D and that only the high level setup commands are used with language specific %D interfaces. -% \protected\def\mult_interfaces_let #1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -% \protected\def\mult_interfaces_lete#1#2{\expandafter\let \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname\empty} -% \protected\def\mult_interfaces_def #1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -% \protected\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -% \protected\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} -% \protected\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} - % \startinterface english - \protected\def\mult_interfaces_let #1#2{\expandafter \let\csname#1#2\endcsname} - \protected\def\mult_interfaces_lete#1#2{\expandafter \let\csname#1#2\endcsname\empty} - \protected\def\mult_interfaces_def #1#2{\expandafter \def\csname#1#2\endcsname} - \protected\def\mult_interfaces_edef#1#2{\expandafter\edef\csname#1#2\endcsname} - \protected\def\mult_interfaces_gdef#1#2{\expandafter\gdef\csname#1#2\endcsname} - \protected\def\mult_interfaces_xdef#1#2{\expandafter\xdef\csname#1#2\endcsname} + \protected\def\mult_interfaces_let #1#2{\letcsname#1#2\endcsname} + \protected\def\mult_interfaces_lete#1#2{\letcsname#1#2\endcsname\empty} + \protected\def\mult_interfaces_def #1#2{\defcsname#1#2\endcsname} + \protected\def\mult_interfaces_edef#1#2{\edefcsname#1#2\endcsname} + \protected\def\mult_interfaces_gdef#1#2{\globaldef\csname#1#2\endcsname} + \protected\def\mult_interfaces_xdef#1#2{\globaledef\csname#1#2\endcsname} % \stopinterface %D Do, we only interface the assignment definition: @@ -279,7 +254,7 @@ \protected\def\mult_interfaces_adef#1#2{\expandafter\def \csname#1\ifcsname\k!prefix!#2\endcsname\csname\k!prefix!#2\endcsname\else#2\fi\endcsname} \startinterface english - \protected\def\mult_interfaces_adef#1#2{\expandafter \def\csname#1#2\endcsname} + \protected\def\mult_interfaces_adef#1#2{\defcsname#1#2\endcsname} \stopinterface % the commented detokenized variant that backtracks ... needs testing usage first @@ -299,19 +274,17 @@ \def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter} \protected\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only) - {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing - \def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}% - \def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% - %\def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ? - %\def#5##1##2{\ifx##1\relax\??empty\else#4##1{##2}\fi}% is {} needed around ##1 ? - %\def#5##1##2{\ifx##1\relax^^^^0019\else#4##1{##2}\fi}% is {} needed around ##1 ? - \edef#5##1##2{\noexpand\ifx##1\relax\??empty\noexpand\else\noexpand#4##1{##2}\noexpand\fi}% is {} needed around ##1 ? - \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}% - \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack - \def#8##1{\begincsname#1#2:##1\endcsname} - \def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}} - -\protected\def\installparameterhandler#1#2% + {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing + \frozen\def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}% + \frozen\def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% + \frozen\edef#5##1##2{\noexpand\ifx##1\relax\??empty\noexpand\else\noexpand#4##1{##2}\noexpand\fi}% is {} needed around ##1 ? + \frozen\def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}% + \frozen\def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack + \frozen\def#8##1{\begincsname#1#2:##1\endcsname}% + % TODO + \frozen\def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}} + +\permanent\protected\def\installparameterhandler#1#2% {\normalexpanded {\mult_interfaces_install_parameter_handler {\noexpand#1}% \??aa @@ -325,10 +298,10 @@ \expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone \protected\def\mult_interfaces_install_root_parameter_handler#1#2#3% - {\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root - \def#3##1{\begincsname#1:##1\endcsname}} + {\frozen\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root + \frozen\def#3##1{\begincsname#1:##1\endcsname}} -\protected\def\installrootparameterhandler#1#2% +\permanent\protected\def\installrootparameterhandler#1#2% {\normalexpanded {\mult_interfaces_install_root_parameter_handler {\noexpand#1}% \??aa @@ -337,18 +310,17 @@ \protected\def\mult_interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9% {\ifx#2\relax\let#2\empty\fi - \def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used? - \def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% - %\def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}% - \def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}% - \def#6{#1#2:}% - \def#7##1{#1##1:}% - %\def#8{\ifx#2\empty\orelse\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi}% - \def#8{\ifempty#2\orelse\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi}% - \protected\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}} - -\protected\def\installparameterhashhandler#1#2% - {\expandafter\let\csname#2namespace\endcsname#1% + \frozen\def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used? + \frozen\def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% + \frozen\def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}% + \frozen\def#6{#1#2:}% + \frozen\def#7##1{#1##1:}% + \frozen\def#8{\ifempty#2\orelse\ifcsname#1#2:\s!parent\endcsname\else\letcsname#1#2:\s!parent\endcsname#1\fi}% + \frozen\protected\def#9##1{\edefcsname#1##1:\s!parent\endcsname{#1#2}}} + +\permanent\protected\def\installparameterhashhandler#1#2% +% {\expandafter\let\csname#2namespace\endcsname#1% + {\letcsname#2namespace\endcsname#1% \normalexpanded {\mult_interfaces_install_parameter_hash_handler {\noexpand#1}% \??aa @@ -365,23 +337,16 @@ % todo: inline the def/let -% \protected\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% -% {\ifx#2\relax\let#2\empty\fi -% \protected\def#3{\mult_interfaces_def {#1#2:}}% ##1 {##2} (braces are mandate) -% \protected\def#4{\mult_interfaces_edef{#1#2:}}% ##1 {##2} (braces are mandate) -% \protected\def#5{\mult_interfaces_let {#1#2:}}% ##1 ##2 -% \protected\def#6{\mult_interfaces_lete{#1#2:}}}% ##1 -% % \startinterface english \protected\def\mult_interfaces_install_parameter_set_handler#1#2#3#4#5#6% {\ifx#2\relax\let#2\empty\fi - \protected\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) - \protected\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) - \protected\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2 - \protected\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1 + \frozen\protected\def#3##1{\defcsname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) + \frozen\protected\def#4##1{\edefcsname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) + \frozen\protected\def#5##1{\letcsname#1#2:##1\endcsname}% ##1 ##2 + \frozen\protected\def#6##1{\letcsname#1#2:##1\endcsname\empty}}% ##1 % \stopinterface -\protected\def\installparametersethandler#1#2% +\permanent\protected\def\installparametersethandler#1#2% {\normalexpanded {\mult_interfaces_install_parameter_set_handler {\noexpand#1}% \??aa @@ -398,23 +363,19 @@ \let\currentcolorparameter\empty \protected\def\mult_interfaces_install_style_and_color_handler#1#2#3#4% - {\protected\def#2##1##2% style color + {\frozen\protected\def#2##1##2% style color {\edef\currentstyleparameter{#1{##1}}% this name is public (can also set color e.g. in underline) - %\ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi \ifempty\currentstyleparameter\else\dousecurrentstyleparameter\fi \edef\currentcolorparameter{#1{##2}}% this name is public (so we do this after the style switch) - %\ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}% \ifempty\currentcolorparameter\else\dousecurrentcolorparameter\fi}% - \protected\def#3##1% style + \frozen\protected\def#3##1% style {\edef\currentstyleparameter{#1{##1}}% this name is public - %\ifx\currentstyleparameter\empty\else\dousecurrentstyleparameter\fi}% \ifempty\currentstyleparameter\else\dousecurrentstyleparameter\fi}% - \protected\def#4##1% color + \frozen\protected\def#4##1% color {\edef\currentcolorparameter{#1{##1}}% this name is public - %\ifx\currentcolorparameter\empty\else\dousecurrentcolorparameter\fi}}% \ifempty\currentcolorparameter\else\dousecurrentcolorparameter\fi}} -\protected\def\installstyleandcolorhandler#1#2% +\permanent\protected\def\installstyleandcolorhandler#1#2% {\normalexpanded {\mult_interfaces_install_style_and_color_handler \expandafter\noexpand\csname #2parameter\endcsname @@ -424,123 +385,107 @@ \let\definehandlerparent\empty -% \def\mult_check_for_parent#1#2#3#4% -% {\ifcsname#1#4:\s!parent\endcsname \else \ifx#4\empty \else -% \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}% -% \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}% -% \fi \fi} - \def\mult_check_for_parent#1#2#3#4% {\ifcsname#1#4:\s!parent\endcsname\orelse\ifx#4\empty\else \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}% +% \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}% + \edefcsname#1#4:\s!parent\endcsname{#2}% \fi} -%def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\space\fi} -%def\getparentchain #1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\fi} -%def\getcurrentparentchain#1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\fi} - \def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\lastnamedcs\space\fi} \def\getparentchain #1#2{\begincsname#1#2:\s!chain\endcsname} \def\getcurrentparentchain#1#2{\begincsname#1#2:\s!chain\endcsname} -\protected\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8#9% why is \expanded still needed in clones - {\ifx#4\relax\let#4\empty\fi % see \defineregister - \protected\def#2{\dotripleempty#5}% +\protected\def\mult_interfaces_install_define_handler#1#2#3#4#5#6#7#8% why is \expanded still needed in clones + {\ifx#4\relax\let#4\empty\fi % see \defineregister + \newtoks#5% \newtoks#6% - \newtoks#7% - \protected\def#5[##1][##2][##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child] - {\let#9#4% - \edef#4{##1}% - \ifthirdargument - \the#6% predefine - \edef#8{##2}% - \mult_check_for_parent{#1}{#3}#4#8% - \expandafter\edef\csname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}% - \mult_interfaces_get_parameters{#1#4:}[##3]% - \orelse\ifsecondargument - \the#6% predefine + \frozen\tolerant\protected\def#2[##1]##*[##2]##*[##3]% [child][parent][settings] | [child][settings] | [child][parent] | [child] + {\let#8#4% + % watch out: no \edef#4{##1} before the ifarguments because #1 can have macros + \ifarguments + \let#4\empty + \the#5% predefine + \let#7\empty + \letcsname#1#4:\s!chain\endcsname\empty + \edefcsname#1#4:\s!parent\endcsname{#3}% + \or + \edef#4{##1}% + \the#5% predefine + \let#7\empty + \edefcsname#1#4:\s!chain\endcsname{##1}% + \edefcsname#1#4:\s!parent\endcsname{#3}% + \or + \edef#4{##1}% + \the#5% predefine \relax - %\ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##2}=^^^^0003^^^^0003^^^^0004% -% \ifcondition\mult_aux_no_assignment_indeed##2\ignorearguments -% \edef#8{##2}% -% \mult_check_for_parent{#1}{#3}#4#8% -% \expandafter\edef\csname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}% -% \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}% -% \else -% \let#8\empty -% \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}% -% \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}% -% \mult_interfaces_get_parameters{#1#4:}[##2]% -% \fi \ifhastok={##2}% - \let#8\empty - \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}% + \let#7\empty + \edefcsname#1#4:\s!chain\endcsname{##1}% + \edefcsname#1#4:\s!parent\endcsname{#3}% \mult_interfaces_get_parameters{#1#4:}[##2]% \else - \edef#8{##2}% - \ifempty#8% - \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}% + \edef#7{##2}% + \ifempty#7% + \edefcsname#1#4:\s!chain\endcsname{##1}% + \edefcsname#1#4:\s!parent\endcsname{#3}% \else - \mult_check_for_parent{#1}{#3}#4#8% - \expandafter\edef\csname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#1##2}% + \mult_check_for_parent{#1}{#3}#4#7% + \edefcsname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}% + \edefcsname#1#4:\s!parent\endcsname{#1##2}% \fi \fi - \else - \the#6% predefine - \let#8\empty - \expandafter\edef\csname#1#4:\s!chain\endcsname{##1}% - \expandafter\edef\csname#1#4:\s!parent\endcsname{#3}% + \or + \edef#4{##1}% + \the#5% predefine + \edef#7{##2}% + \mult_check_for_parent{#1}{#3}#4#7% + \edefcsname#1#4:\s!chain\endcsname{\mult_interfaces_chain#1{##2}##1}% + \edefcsname#1#4:\s!parent\endcsname{#1##2}% + \mult_interfaces_get_parameters{#1#4:}[##3]% \fi - \the#7% - \let#4#9}} + \the#6% + \let#4#8}} -\protected\def\installdefinehandler#1#2#3% +\permanent\protected\def\installdefinehandler#1#2#3% {\normalexpanded {\mult_interfaces_install_define_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname define#2\endcsname {\noexpand#3}% root \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname define_#2\endcsname % semi-public \expandafter\noexpand\csname everypreset#2\endcsname \expandafter\noexpand\csname everydefine#2\endcsname \expandafter\noexpand\csname current#2parent\endcsname \expandafter\noexpand\csname saved_defined_#2\endcsname}} -\protected\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8#9% +\protected\def\mult_interfaces_install_setup_handler#1#2#3#4#5#6#7#8% {\ifx#3\relax\let#3\empty\fi - \protected\def#2{\dodoubleempty#4}% - \protected\def#6{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it - \newtoks#5% - \newtoks#8% - \protected\def#4[##1][##2]% maybe helper - {\let#7#3% - \ifsecondargument - \def#9####1% we will have a simple one as well + \protected\def#5{\mult_interfaces_get_parameters{#1#3:}}% no every ! don't change it + \newtoks#4% + \newtoks#7% + \frozen\tolerant\protected\def#2[##1]##*[##2]% maybe helper + {\let#6#3% + \ifnum\lastarguments=\plustwo + \def#8####1% we will have a simple one as well {\edef#3{####1}% \mult_interfaces_get_parameters{#1#3:}[##2]% - \the#5}% - \processcommalist[##1]#9% + \the#4}% + \processcommalist[##1]#8% \else \let#3\empty \mult_interfaces_get_parameters{#1:}[##1]% - \the#5% + \the#4% \fi - \let#3#7% - \the#8}} + \let#3#6% + \the#7}} -\protected\def\installsetuphandler#1#2% +\permanent\protected\def\installsetuphandler#1#2% {\normalexpanded {\mult_interfaces_install_setup_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname setupcurrent#2\endcsname \expandafter\noexpand\csname saved_setup_current#2\endcsname @@ -552,10 +497,9 @@ \let\doingrootsetnamed \plusthree % \setuplayout[name] \let\doingrootsetroot \plusfour % \setuplayout -\protected\def\mult_interfaces_install_switch_setup_handler_a#1#2#3#4#5% - {\ifx#3\relax\let#3\empty\fi - \protected\def#2{\dodoubleempty#4}% - \protected\def#5{\mult_interfaces_get_parameters{#1#3:}}} +\protected\def\mult_interfaces_install_switch_setup_handler_a#1#2#3% + {\ifx#2\relax\let#2\empty\fi + \frozen\protected\def#3{\mult_interfaces_get_parameters{#1#2:}}} \protected\def\mult_interfaces_install_switch_setup_handler_b#1#2#3#4#5#6#7#8#9% {\newtoks#5% @@ -563,37 +507,15 @@ \newtoks#8% \newtoks#9% \ifx#6\relax\let#6\empty\fi - \protected\def#4[##1][##2]% maybe helper - {\ifsecondargument % no commalist here - % \setuplayout[whatever][key=value] - \let#7#3% - \let#6#3% - \edef#3{##1}% - #2\doingrootsetupnamed - \mult_interfaces_get_parameters{#1#3:}[##2]% + \frozen\tolerant\protected\def#4[##1]##*[##2]% maybe helper + {\ifarguments + % \setuplayout + \let#6#3% % previous becomes current + \let#3\empty % current becomes empty + #2\doingrootsetroot \the#5% - \ifx#3#6\the#8\fi % only switchsetups if previous == current - \let#3#7% - \orelse\iffirstargument - %\ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##1}=^^^^0003^^^^0003^^^^0004% -% \ifcondition\mult_aux_no_assignment_indeed##1\ignorearguments -% % \setuplayout[whatever] -% \let#6#3% % previous becomes current -% \edef#3{##1}% this will catch reset so one needs to test for it -% #2\doingrootsetnamed -% \the#5% % we can check for previous vs current -% \the#8% switchsetups -% \else -% % \setuplayout[key=value] -% \let#7#3% -% \let#6#3% -% \let#3\empty -% #2\doingrootsetuproot -% \mult_interfaces_get_parameters{#1:}[##1]% -% \the#5% -% \the#8% switchsetups -% \let#3#7% -% \fi + \the#8% switchsetups + \or \ifhastok={##1}% % \setuplayout[key=value] \let#7#3% @@ -620,111 +542,113 @@ \the#8% switchsetups \fi \fi - \else - % \setuplayout - \let#6#3% % previous becomes current - \let#3\empty % current becomes empty - #2\doingrootsetroot + \or + % \setuplayout[whatever][key=value] + \let#7#3% + \let#6#3% + \edef#3{##1}% + #2\doingrootsetupnamed + \mult_interfaces_get_parameters{#1#3:}[##2]% \the#5% - \the#8% switchsetups + \ifx#3#6\the#8\fi % only switchsetups if previous == current + \let#3#7% \fi #2\zerocount % mode is always zero at the end \the#9}} -\protected\def\installswitchsetuphandler#1#2% +\permanent\protected\def\installswitchsetuphandler#1#2% {\normalexpanded {\mult_interfaces_install_switch_setup_handler_a {\noexpand#1}% \??aa - \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname setupcurrent#2\endcsname \mult_interfaces_install_switch_setup_handler_b {\noexpand#1}% \??aa \expandafter\noexpand\csname #2setupmode\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname setup_#2\endcsname % semi-public + \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname previous#2\endcsname \expandafter\noexpand\csname saved_setup_current#2\endcsname \expandafter\noexpand\csname everyswitch#2\endcsname \expandafter\noexpand\csname everysetup#2root\endcsname}} -\protected\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8#9% +\protected\def\mult_interfaces_install_auto_setup_handler#1#2#3#4#5#6#7#8% {\ifx#3\relax\let#3\empty\fi - \protected\def#2{\dotripleempty#4}% - \protected\def#6{\mult_interfaces_get_parameters{#1#3:}}% - \newtoks#5% - \def#4[##1][##2][##3]% - {\let#8#3% - \ifthirdargument - \def#9####1% - {\edef#3{####1}% - \expandafter\def\csname#1#3:\s!parent\endcsname{#1##2}% - \mult_interfaces_get_parameters{#1#3:}[##3]% always sets parent - \the#5}% - \processcommalist[##1]#9% - \orelse\ifsecondargument - \def#9####1% - {\edef#3{####1}% - #7% checks parent and sets if needed - \mult_interfaces_get_parameters{#1#3:}[##2]% - \the#5}% - \processcommalist[##1]#9% - \else + \frozen\protected\def#5{\mult_interfaces_get_parameters{#1#3:}}% + \newtoks#4% + \frozen\tolerant\protected\def#2[##1]##*[##2]##*[##3]% + {\let#7#3% + \ifarguments \let#3\empty - \mult_interfaces_get_parameters{#1:}[##1]% \the#5% + \or + \let#3\empty + \mult_interfaces_get_parameters{#1:}[##1]% + \the#4% + \or + \def#8####1% + {\edef#3{####1}% + #6% checks parent and sets if needed + \mult_interfaces_get_parameters{#1#3:}[##2]% + \the#4}% + \processcommalist[##1]#8% + \or + \def#8####1% + {\edef#3{####1}% + \defcsname#1#3:\s!parent\endcsname{#1##2}% + \mult_interfaces_get_parameters{#1#3:}[##3]% always sets parent + \the#4}% + \processcommalist[##1]#8% \fi - \let#3#8}} + \let#3#7}} -\protected\def\installautosetuphandler#1#2% +\permanent\protected\def\installautosetuphandler#1#2% {\normalexpanded {\mult_interfaces_install_auto_setup_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname \expandafter\noexpand\csname current#2\endcsname - \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname everysetup#2\endcsname \expandafter\noexpand\csname setupcurrent#2\endcsname \expandafter\noexpand\csname check#2parent\endcsname \expandafter\noexpand\csname saved_setup_current#2\endcsname \expandafter\noexpand\csname nested_setup_current#2\endcsname}} -\protected\def\installbasicparameterhandler#1#2% +\permanent\protected\def\installbasicparameterhandler#1#2% {\installparameterhandler {#1}{#2}% \installparameterhashhandler{#1}{#2}% \installparametersethandler {#1}{#2}% \installrootparameterhandler{#1}{#2}} -\protected\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self) +\permanent\protected\def\installbasicautosetuphandler#1#2#3% \??self name \??parent (can be \??self) {\installbasicparameterhandler{#1}{#2}% \installautosetuphandler {#1}{#2}} -\protected\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self) +\permanent\protected\def\installstylisticautosetuphandler#1#2#3% \??self name \??parent (can be \??self) {\installbasicparameterhandler{#1}{#2}% \installautosetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} -\protected\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self) +\permanent\protected\def\installcommandhandler#1#2#3% \??self name \??parent (can be \??self) {\installbasicparameterhandler{#1}{#2}% \installdefinehandler {#1}{#2}{#3}% \installsetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} -\protected\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self) +\permanent\protected\def\installswitchcommandhandler#1#2#3% \??self name \??parent (can be \??self) {\installbasicparameterhandler{#1}{#2}% \installdefinehandler {#1}{#2}{#3}% \installswitchsetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} -\protected\def\installautocommandhandler#1#2#3% automatically defined cloned setups +\permanent\protected\def\installautocommandhandler#1#2#3% automatically defined cloned setups {\installbasicparameterhandler{#1}{#2}% \installdefinehandler {#1}{#2}{#3}% \installautosetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} -\protected\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining +\permanent\protected\def\installsimplecommandhandler#1#2#3% no define (experiment) - use \check*parent when defining {\installbasicparameterhandler{#1}{#2}% \installsetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} @@ -741,13 +665,11 @@ %D We don't need colons for such simple cases. \protected\def\mult_interfaces_install_direct_parameter_handler#1#2#3#4#5% -%%{\def#3##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}% - {\def#3##1{\begincsname#1##1\endcsname}% - \def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}% - % \def#4##1{\mult_interfaces_detokenize{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}}% - \def#5##1{\begincsname#1##1\endcsname}} + {\frozen\def#3##1{\begincsname#1##1\endcsname}% + \frozen\def#4##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}% + \frozen\def#5##1{\begincsname#1##1\endcsname}} -\protected\def\installdirectparameterhandler#1#2% +\permanent\protected\def\installdirectparameterhandler#1#2% {\normalexpanded {\mult_interfaces_install_direct_parameter_handler {\noexpand#1}% @@ -756,36 +678,28 @@ \expandafter\noexpand\csname detokenized#2parameter\endcsname \expandafter\noexpand\csname direct#2parameter\endcsname}} -\protected\def\mult_interfaces_install_direct_setup_handler#1#2#3#4#5% - {\protected\def#2{\dosingleempty#3}% - \newtoks#5% - \def#3[##1]{\mult_interfaces_get_parameters#1[##1]\the#5}% - \def#4{\mult_interfaces_get_parameters#1}} +\protected\def\mult_interfaces_install_direct_setup_handler#1#2#3#4% + {\newtoks#4% + \frozen\protected\def#2[##1]{\ifarguments\or\mult_interfaces_get_parameters#1[##1]\fi\the#4}% + \frozen\def#3{\mult_interfaces_get_parameters#1}} -\protected\def\installdirectsetuphandler#1#2% +\permanent\protected\def\installdirectsetuphandler#1#2% {\normalexpanded {\mult_interfaces_install_direct_setup_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname setup#2\endcsname - \expandafter\noexpand\csname setup_#2\endcsname % semi-public \expandafter\noexpand\csname setupcurrent#2\endcsname % no \every (we use 'current' for consistency) \expandafter\noexpand\csname everysetup#2\endcsname}} -% \protected\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% -% {\protected\def#2{\mult_interfaces_def #1}% -% \protected\def#3{\mult_interfaces_edef#1}% -% \protected\def#4{\mult_interfaces_let #1}% -% \protected\def#5{\mult_interfaces_let #1\empty}}% - % \startinterface english \protected\def\mult_interfaces_install_direct_parameter_set_handler#1#2#3#4#5% - {\protected\def#2##1{\expandafter \def\csname#1##1\endcsname}% - \protected\def#3##1{\expandafter\edef\csname#1##1\endcsname}% - \protected\def#4##1{\expandafter \let\csname#1##1\endcsname}% - \protected\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}% + {\frozen\protected\def#2##1{\defcsname#1##1\endcsname}% + \frozen\protected\def#3##1{\edefcsname#1##1\endcsname}% + \frozen\protected\def#4##1{\letcsname#1##1\endcsname}% + \frozen\protected\def#5##1{\letcsname#1##1\endcsname\empty}}% % \stopinterface -\protected\def\installdirectparametersethandler#1#2% +\permanent\protected\def\installdirectparametersethandler#1#2% {\normalexpanded {\mult_interfaces_install_direct_parameter_set_handler {\noexpand#1}% \??aa @@ -794,15 +708,15 @@ \expandafter\noexpand\csname let#2parameter\endcsname \expandafter\noexpand\csname reset#2parameter\endcsname}} -\let\installdirectstyleandcolorhandler\installstyleandcolorhandler +\aliased\let\installdirectstyleandcolorhandler\installstyleandcolorhandler -\protected\def\installdirectcommandhandler#1#2% +\permanent\protected\def\installdirectcommandhandler#1#2% {\installdirectparameterhandler {#1}{#2}% \installdirectsetuphandler {#1}{#2}% \installdirectparametersethandler {#1}{#2}% \installdirectstyleandcolorhandler{#1}{#2}} -\protected\def\installsetuponlycommandhandler#1#2% +\permanent\protected\def\installsetuponlycommandhandler#1#2% {\installdirectparameterhandler{#1}{#2}% \installdirectsetuphandler {#1}{#2}% }% maybe \installdirectparametersethandler {#1}{#2}% @@ -830,67 +744,48 @@ % yes:\twoparameter{alpha}\par % yes:\twoparameter{beta}\par -\protected\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance} - {\expandafter\edef\csname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}} +\permanent\protected\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance} + {\edefcsname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}} -\protected\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance} - {\expandafter\edef\csname#1#2:\s!parent\endcsname{#3#4}} +\permanent\protected\def\relateparameterhandlersbyns#1#2#3#4% {from} {instance} {to} {instance} + {\edefcsname#1#2:\s!parent\endcsname{#3#4}} %D Here is another experiment: -\protected\def\installactionhandler#1% - {\normalexpanded - {\mult_interfaces_install_action_handler - {#1}% - \expandafter\noexpand\csname current#1\endcsname - \expandafter\noexpand\csname setupcurrent#1\endcsname - \expandafter\noexpand\csname #1_action\endcsname}} - -% \protected\def\mult_interfaces_install_action_handler#1#2#3#4% -% {\protected\expandafter\def\csname#1\endcsname{\dodoubleempty#4}% -% \protected\def#4[##1][##2]% -% {\begingroup -% \ifsecondargument -% \edef#2{##1}% -% #3[##2]% -% \orelse\iffirstargument -% \doifelseassignment{##1} -% {\let#2\empty -% #3[##1]}% -% {\edef#2{##1}}% -% \else -% \let#2\empty -% \fi -% \directsetup{handler:action:#1}% -% \endgroup}} - -\protected\def\mult_interfaces_install_action_handler#1#2#3#4% - {\protected\expandafter\def\csname#1\endcsname{\dodoubleempty#4}% - \protected\def#4[##1][##2]% +\protected\def\mult_interfaces_install_action_handler#1#2#3% +% {\frozen\tolerant\protected\expandafter\def\csname#1\endcsname[##1]##*[##2]% + {\frozen\tolerant\protected\defcsname#1\endcsname[##1]##*[##2]% {\begingroup - \ifsecondargument - \edef#2{##1}% - #3[##2]% - \orelse\iffirstargument + \ifarguments + \let#2\empty + \or %\ifcondition\expandafter\mult_check_for_assignment_indeed_begin_\detokenize{##1}=^^^^0003^^^^0003^^^^0004% -% \ifcondition\mult_aux_no_assignment_indeed##1\ignorearguments -% \edef#2{##1}% -% \else -% \let#2\empty -% #3[##1]% -% \fi + % \ifcondition\mult_aux_no_assignment_indeed##1\ignorearguments + % \edef#2{##1}% + % \else + % \let#2\empty + % #3[##1]% + % \fi \ifhastok={##1}% \let#2\empty #3[##1]% \else \edef#2{##1}% \fi - \else - \let#2\empty + \or + \edef#2{##1}% + #3[##2]% \fi \directsetup{handler:action:#1}% \endgroup}} +\permanent\protected\def\installactionhandler#1% + {\normalexpanded + {\mult_interfaces_install_action_handler + {#1}% + \expandafter\noexpand\csname current#1\endcsname + \expandafter\noexpand\csname setupcurrent#1\endcsname}} + % First we had, in tune with the regular system variables: % % \starttyping @@ -918,30 +813,23 @@ \newcount\c_mult_interfaces_n_of_namespaces -%def\v_interfaces_prefix_template{\number \c_mult_interfaces_n_of_namespaces>} -%def\v_interfaces_prefix_template{\characters\c_mult_interfaces_n_of_namespaces>} - -%def\v_interfaces_prefix_template % consistently %03i> -% {\ifnum\c_mult_interfaces_n_of_namespaces<\plusten00\orelse\ifnum\c_mult_interfaces_n_of_namespaces<\plushundred0\fi -% \number\c_mult_interfaces_n_of_namespaces>} - \def\v_interfaces_prefix_template {\number\c_mult_interfaces_n_of_namespaces>} -\protected\def\installnamespace#1% for modules and users +\permanent\protected\def\installnamespace#1% for modules and users {\ifcsname ????#1\endcsname \writestatus\m!system{duplicate user namespace '#1'}\wait \else \global\advance\c_mult_interfaces_n_of_namespaces\plusone - \expandafter\edef\csname ????#1\endcsname{\v_interfaces_prefix_template}% + \immutable\edefcsname ????#1\endcsname{\v_interfaces_prefix_template}% \fi} -\protected\def\installcorenamespace#1% +\permanent\protected\def\installcorenamespace#1% {\ifcsname ??#1\endcsname \writestatus\m!system{duplicate core namespace '#1'}\wait \else \global\advance\c_mult_interfaces_n_of_namespaces\plusone - \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template}% + \immutable\edefcsname ??#1\endcsname{\v_interfaces_prefix_template}% \clf_registernamespace\c_mult_interfaces_n_of_namespaces{#1}% \fi} @@ -961,20 +849,19 @@ \letvalue\??dummy\empty - \def\dummyparameter #1{\begincsname\??dummy#1\endcsname} - \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname} -\protected\def\setdummyparameter #1{\expandafter\def\csname\??dummy#1\endcsname} -\protected\def\setexpandeddummyparameter#1{\expandafter\edef\csname\??dummy#1\endcsname} -\protected\def\letdummyparameter #1{\expandafter\let\csname\??dummy#1\endcsname} +\permanent \def\dummyparameter #1{\begincsname\??dummy#1\endcsname} +\permanent \def\directdummyparameter #1{\begincsname\??dummy#1\endcsname} +\permanent\protected\def\setdummyparameter #1{\defcsname\??dummy#1\endcsname} +\permanent\protected\def\setexpandeddummyparameter#1{\edefcsname\??dummy#1\endcsname} +\permanent\protected\def\letdummyparameter #1{\letcsname\??dummy#1\endcsname} -% \protected\def\getdummyparameters -% {\mult_interfaces_get_parameters\??dummy} +\edef\mult_interfaces_dummy{\??dummy} % nor immutable -\protected\def\getdummyparameters[#1% +\permanent\protected\def\getdummyparameters[#1% {\if\noexpand#1]% \expandafter\gobbleoneargument \else - \let\m_mult_interfaces_namespace\??dummy + \let\m_mult_interfaces_namespace\mult_interfaces_dummy \expandafter\mult_interfaces_get_parameters_indeed \fi#1} @@ -1025,13 +912,10 @@ % % This is a user (module) command: -\protected\def\definenamespace - {\dodoubleargument\mult_interfaces_define_name_space} - -\def\mult_interfaces_define_name_space[#1][#2]% namespace settings +\permanent\tolerant\protected\def\definenamespace[#1]#*[#2]% namespace settings {\clf_definenamespace{#1}{#2}} -\def\listnamespaces +\permanent\protected\def\listnamespaces {\clf_listnamespaces} %D Helper: @@ -1040,61 +924,52 @@ %D \showparentchain{@@am}{left} %D \stoptyping -\protected\def\showparentchain#1#2% +\permanent\protected\def\showparentchain#1#2% {\writestatus\m!system{chain: [ \mult_interfaces_show_parent_chain{#1#2}]}} -% \def\mult_interfaces_show_parent_chain#1% -% {#1 => % -% \ifcsname#1:\s!parent\endcsname -% \expandafter\mult_interfaces_show_parent_chain\csname#1:\s!parent\endcsname -% \fi} - \def\mult_interfaces_show_parent_chain#1% {#1 => % \ifcsname#1:\s!parent\endcsname - %\expandafter\mult_interfaces_show_parent_chain\csname#1:\s!parent\endcsname \expandafter\mult_interfaces_show_parent_chain\lastnamedcs \fi} %D Another helper (needs to be applied): -\protected\def\doifelsecommandhandler#1#2% namespace name +\permanent\protected\def\doifelsecommandhandler#1#2% namespace name {\ifcsname#1#2:\s!parent\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\let\doifcommandhandlerelse\doifelsecommandhandler +\aliased\let\doifcommandhandlerelse\doifelsecommandhandler -\protected\def\doifcommandhandler#1#2% namespace name +\permanent\protected\def\doifcommandhandler#1#2% namespace name {\ifcsname#1#2:\s!parent\endcsname \expandafter\firstofoneargument \else \expandafter\gobbleoneargument \fi} -\protected\def\doifnotcommandhandler#1#2% namespace name +\permanent\protected\def\doifnotcommandhandler#1#2% namespace name {\ifcsname#1#2:\s!parent\endcsname \expandafter\gobbleoneargument \else \expandafter\firstofoneargument \fi} -\let\doifcommandhandlerelse\doifelsecommandhandler - % another set of (fast) helpers (grep for usage): -\def\expandnamespaceparameter#1#2#3% \??xx \getp \c!xx \v!yy +\permanent\def\expandnamespaceparameter#1#2#3% \??xx \getp \c!xx \v!yy {\csname#1\ifcsname#1\expandafter\expandafter\expandafter\mult_aux_expand_namespace_parameter#2#3} \def\mult_aux_expand_namespace_parameter#1#2% \cs \v!yy {#1\endcsname#1\else#2\fi\endcsname} -\def\expandnamespacemacro#1#2#3% \??xx \some_edefed_cs \c!yy +\permanent\def\expandnamespacemacro#1#2#3% \??xx \some_edefed_cs \c!yy {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname} -\def\expandnamespacevalue#1#2% \??xx {...} \c!yy == optimized \expandcheckedcsname +\permanent\def\expandnamespacevalue#1#2% \??xx {...} \c!yy == optimized \expandcheckedcsname {\csname#1\ifcsname#1\normalexpanded{\noexpand\syst_helpers_expand_checked_value{#2}}} \def\syst_helpers_expand_checked_value#1#2% @@ -1120,11 +995,6 @@ % many assignments and mechanism that do are also slow; the advantage is mostly nicer % in tracing -\def\s!simple{simple} -\def\s!single{single} -\def\s!double{double} -\def\s!triple{triple} - \let\c_mult_set\relax \protected\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7% @@ -1134,23 +1004,23 @@ {\expandafter\let\expandafter\c_mult_set\csname #1_t_#6\endcsname \ifx\c_mult_set\relax \expandafter\newtoks\c_mult_set - \expandafter\let\csname #1_t_#6\endcsname\c_mult_set + \letcsname#1_t_#6\endcsname\c_mult_set \fi} - \protected\def#4##1% + \frozen\protected\def#4##1% {\pushmacro#6% \advance#3\plusone \edef#6{##1}% \unprotect}% - \protected\def#5% + \frozen\protected\def#5% {\protect \advance#3\minusone \popmacro#6}% - \protected\def#7##1% + \frozen\protected\def#7##1% {\edef#6{##1}% #2% \the\c_mult_set\relax}} -\protected\def\installdefinitionset#1#2% +\permanent\protected\def\installdefinitionset#1#2% {\normalexpanded {\mult_interfaces_install_definition_set {\noexpand#1}% \??aa @@ -1163,20 +1033,16 @@ \protected\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc {\let#5#2% - \protected\def#2% + \frozen\protected\def#2% {\ifcase#4\relax\expandafter#5\else\expandafter#6\fi}% - \protected\def#6% - {\dodoubleempty#7}% - \protected\def#7[##1][##2]% - {\ifsecondargument - %#3\c_mult_set\expandafter{\the\c_mult_set#9[##1][##2]}% - #3\toksapp\c_mult_set{#9[##1][##2]}% - \orelse\iffirstargument - %#3\c_mult_set\expandafter{\the\c_mult_set#8[##1]}% - #3\toksapp\c_mult_set{#8[##1]}% + \tolerant\protected\def#6[##1]##*[##2]% + {\ifarguments\or + #3\toksapp\c_mult_set{#7[##1]}% + \or + #3\toksapp\c_mult_set{#8[##1][##2]}% \fi}} -\protected\def\installdefinitionsetmember#1#2#3#4% +\permanent\protected\def\installdefinitionsetmember#1#2#3#4% {\normalexpanded {\mult_interfaces_install_definition_set_member {\noexpand#3}% \??aa @@ -1185,58 +1051,33 @@ \expandafter\noexpand\csname #2_nesting_depth\endcsname \expandafter\noexpand\csname normal_setup_#4\endcsname \expandafter\noexpand\csname delayed_setup_#4\endcsname - \expandafter\noexpand\csname do_delayed_setup_#4\endcsname \expandafter\noexpand\csname setup#4_\s!single\endcsname \expandafter\noexpand\csname setup#4_\s!double\endcsname}} %D Another experiment: \protected\def\mult_interfaces_install_parent_injector#1#2#3#4% - {\protected\def#4##1% - %{\ifx#3\empty + {\frozen\protected\def#4##1% {\ifempty#3% - \expandafter\def\csname#1#2:\s!parent\endcsname{#1##1}% + \defcsname#1#2:\s!parent\endcsname{#1##1}% \fi}} -\protected\def\installparentinjector#1#2% +\permanent\protected\def\installparentinjector#1#2% {\normalexpanded{\mult_interfaces_install_parent_injector {\noexpand#1}% \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname current#2parent\endcsname \expandafter\noexpand\csname inject#2parent\endcsname}} -% Faster but not used that much to make a dent in performance. But, because it's -% cleaner anyway and also gives less tracing, we apply it a few times. - -% \protected\def\syst_helpers_install_macro_stack#1#2#3% -% {\xdef\m_syst_helpers_push_macro{\csstring#1}% -% \ifcsname#3\m_syst_helpers_push_macro\endcsname\else -% \expandafter\newcount\csname#3\m_syst_helpers_push_macro\endcsname -% \expandafter\edef\csname push_macro_\m_syst_helpers_push_macro\endcsname -% {\noexpand\expandafter\glet -% \noexpand\csname\m_syst_helpers_push_macro\noexpand\the\csname#3\m_syst_helpers_push_macro\endcsname\endcsname -% \noexpand#1% -% \global\advance\csname#3\m_syst_helpers_push_macro\endcsname\plusone}% -% \expandafter\edef\csname pop_macro_\m_syst_helpers_push_macro\endcsname -% {\global\advance\csname#3\m_syst_helpers_push_macro\endcsname\minusone -% \noexpand\expandafter#2% -% \noexpand\expandafter\noexpand#1% -% \noexpand\csname\m_syst_helpers_push_macro\noexpand\the\csname#3\m_syst_helpers_push_macro\endcsname\endcsname}% -% \fi} -% -% \protected\def\installmacrostack #1{\syst_helpers_install_macro_stack#1\let \??localpushedmacro } -% \protected\def\installglobalmacrostack#1{\syst_helpers_install_macro_stack#1\glet\??globalpushedmacro} - % The \LUA\ based variant is twice as fast as the above but as said, we don't use % this one that often. It's more about less tracing than speed here. -\protected\def\installmacrostack#1% +\permanent\protected\def\installmacrostack#1% {\ifdefined#1\else\let#1\empty\fi \protected\expandafter\gdef\csname push_macro_\csstring#1\endcsname{\localpushmacro#1}% \protected\expandafter\gdef\csname pop_macro_\csstring#1\endcsname{\localpopmacro #1}} - -\protected\def\installglobalmacrostack#1% +\permanent\protected\def\installglobalmacrostack#1% {\ifdefined#1\else\glet#1\empty\fi \protected\expandafter\gdef\csname push_macro_\csstring#1\endcsname{\globalpushmacro#1}% \protected\expandafter\gdef\csname pop_macro_\csstring#1\endcsname{\globalpopmacro #1}} @@ -1307,30 +1148,26 @@ \installcorenamespace{commalistprocessornext} \installcorenamespace{commalistprocessoraction} -\protected\def\installcommalistprocessor#1#2% 5 macro names overhead - {\protected\expandafter\edef\csname\??commalistprocessor#1\endcsname[% - % {\noexpand\futureexpandis]% - % \noexpand\gobbleoneargument - % \csname\??commalistprocessorpickup#1\endcsname} - %\protected\expandafter\edef\csname\??commalistprocessorpickup#1\endcsname +\permanent\protected\def\installcommalistprocessor#1#2% 5 macro names overhead + {\protected\edefcsname\??commalistprocessor#1\endcsname[% {\csname\??commalistprocessorwrap#1\endcsname\relax}% \relax preserves {} - \protected\expandafter\edef\csname\??commalistprocessorwrap#1\endcsname##1]% + \protected\edefcsname\??commalistprocessorwrap#1\endcsname##1]% {\csname\??commalistprocessorfirst#1\endcsname##1,]} - \protected\expandafter\edef\csname\??commalistprocessorfirst#1\endcsname\relax + \protected\edefcsname\??commalistprocessorfirst#1\endcsname\relax {\csname\??commalistprocessornext#1\endcsname}% - \protected\expandafter\edef\csname\??commalistprocessornext#1\endcsname + \protected\edefcsname\??commalistprocessornext#1\endcsname {\noexpand\futureexpandis]% \noexpand\gobbleoneargument \csname\??commalistprocessoraction#1\endcsname} - \protected\expandafter\edef\csname\??commalistprocessoraction#1\endcsname##1,% + \protected\edefcsname\??commalistprocessoraction#1\endcsname##1,% {\noexpand#2{##1}% \csname\??commalistprocessornext#1\endcsname}} -\protected\def\installcommalistprocessorcommand#1#2% \processor \action +\permanent\protected\def\installcommalistprocessorcommand#1#2% \processor \action {\edef\p_name{\csstring#2}% \installcommalistprocessor\p_name{#2}% \expandafter\let\expandafter#1\csname\??commalistprocessor\p_name\endcsname} -\protected\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname} +\permanent\protected\def\commalistprocessor#1{\csname\??commalistprocessor#1\endcsname} \protect \endinput |