diff --git a/Packages/Manual_tools/format/cc_manual.sty b/Packages/Manual_tools/format/cc_manual.sty index 37f1894a550..fb818f009f7 100644 --- a/Packages/Manual_tools/format/cc_manual.sty +++ b/Packages/Manual_tools/format/cc_manual.sty @@ -69,6 +69,8 @@ % | % | The dimensions \ccFirst and \ccSecond are set to the appropriate % | values. Afterwards, the \ccInitWidths does the rest. +% | \ccInitFunctionWidths and \ccInitConstructorWidths set the +% | \ccFirst and \ccSecond appropriately and call \ccInitWidths afterwards. % +-------------------------------------------------------------------------- \newdimen\ccwIndent @@ -119,6 +121,21 @@ } \ccInitWidths + +% \ccInitFunctionWidths and \ccInitConstructorWidths set the +% \ccFirst and \ccSecond appropriately and call \ccInitWidths afterwards. +\newcommand{\ccInitFunctionWidths}{% + \ccwFirst =\ccwFunctionFirst + \ccwSecond =\ccwFunctionSecond + \ccInitWidths +} +\newcommand{\ccInitConstructorWidths}{% + \ccwFirst =\ccwConstructorFirst + \ccwSecond =\ccwConstructorSecond + \ccInitWidths +} + + % define macros for the vertical structuring % ------------------------------------------ \newcommand{\ccTopSkip}{\smallskip} @@ -169,9 +186,10 @@ \newcommand{\ccTagReplaceInclude}{} % true -> include file prefixes % are replaced when % \ccTagReplacePrefix is also true. -\newcommand{\ccAlternateThreeColumn}{}% true -> function paramters are aligned - % below the opening paranthesis, else - % they are aligned in a fixed column. +\newcommand{\ccLongParamLayout}{} % false -> function parameters are + % aligned below the opening paranthesis, + % else they are aligned in a fixed + % column. % Declaration Layout tags \newcommand{\ccTagRmConstRefPair}{} % true -> removes const & pairs @@ -188,7 +206,7 @@ \def\ccTagChapterAuthor{\ccTrue}% \def\ccTagReplacePrefix{\ccFalse}% \def\ccTagReplaceInclude{\ccFalse}% - \def\ccAlternateThreeColumn{\ccTrue}% + \def\ccLongParamLayout{\ccFalse}% % Declaration Layout tags \def\ccTagRmTrailingConst{\ccTrue}% \def\ccTagRmEigenClassName{\ccTrue}% @@ -196,6 +214,7 @@ \def\ccTagOperatorLayout{\ccTrue}% % portability namings \def\CCalternateThreeColumn{\ccTrue}% + \def\ccAlternateThreeColumn{\ccTrue}% } \newcommand{\ccTagFullDeclarations}{% @@ -206,6 +225,9 @@ } % portability namings +\newcommand{\ccAlternateThreeColumn}{}% true -> function paramters are aligned + % below the opening paranthesis, else + % they are aligned in a fixed column. \newcommand{\CCalternateThreeColumn}{} % activate defaults @@ -421,9 +443,11 @@ % +-------------------------------------------------------------------------- % #1 the macro name for the RCS entry % #2 the RCS entry -\newcommand{\RCSdef}{\begingroup\catcode`\$=12 \RCSdefSet} +\newcommand{\RCSdef}{} +\def\RCSdef{\begingroup\catcode`\$=12 \RCSdefSet} { \catcode`\$=12 - \gdef\RCSdefSet #1$#2${\gdef#1{#2}\endgroup}% + \gdef\RCSdefSetX #1$#2${\gdef#1{#2}}% + \gdef\RCSdefSet #1#2{\RCSdefSetX{#1}#2\endgroup}% } % +-------------------------------------------------------------------------- @@ -623,22 +647,9 @@ \renewcommand{\ccVar}{}% } -\def\ccClassX #1{% +\def\ccClassX #1{% There is no longer a check whether the class has template + % parameters or not. \endgroup - \ccClassXX #1<\end} - - -\def\ccClassXX #1<#2\end{% - \def\xparams{#2}\ifx\xparams\empty - \ccClassXXX{#1}% - \else - \errmessage{Template parameters are not allowed - in a normal class. Use \begin{classtemplate} - instead}>% - \ccClassXXX{#1}% - \fi} - -\def\ccClassXXX #1{% \def\ccPureClassName{#1}% \def\ccPureClassTemplateName{#1}% \renewcommand{\ccClassName}{\hbox{{\ccFont @@ -667,7 +678,7 @@ \def\ccClassTemplateXX #1<#2\end{% \def\xparams{#2}\ifx\xparams\empty - \errmessage{Template parameters missed for + \errmessage{Template parameters missing for class template}>% \ccClassTemplateXXX{#1}<\end% \else @@ -764,9 +775,7 @@ \ccNestedTypeXX{#1}}% } \long\def\ccNestedTypeXX #1#2{% - \ccwFirst =\ccwConstructorFirst - \ccwSecond =\ccwConstructorSecond - \ccInitWidths + \ccInitConstructorWidths \setbox\returntypebox=\hbox{}% \setbox\callnamebox=\hbox{\ccClassTemplateName \ccFont\ccPrintTokens ::\end}% @@ -1061,16 +1070,16 @@ \else\isLastAlphaX #1\end \fi} \def\isLastAlphaX #1#2\end{% - \def\xbody{\isLastAlphaX #2\end}% + \def\xqqbody{\isLastAlphaX #2\end}% \isLetterX #1\end - \def\qqparams{#2}\ifx\qqparams\empty\let\xnext=\relax + \def\qqparams{#2}\ifx\qqparams\empty\let\xqqnext=\relax \else\isEmpty{#2}\ifnum\ccBool=\ccTrue \ccInvert - \let\xnext=\relax + \let\xqqnext=\relax \else - \let\xnext=\xbody + \let\xqqnext=\xqqbody \fi \fi - \xnext} + \xqqnext} % This macro gets a complete C++ declaration for an operator and has to % decide weather it is the parenthesis () operator declaration or not. @@ -1119,9 +1128,7 @@ \ccSeparateTemplate{\ccTemplateLine}{% \constructorcall{#1}}#2(#3)#4\end \else - \ccwFirst =\ccwConstructorFirst - \ccwSecond =\ccwConstructorSecond - \ccInitWidths + \ccInitConstructorWidths \setbox\callnamebox=\hbox{% \ccClassTemplateName\ \ \ccFont\ccVar}% \setbox\functioncallbox=\hbox{\unhcopy\callnamebox @@ -1146,9 +1153,7 @@ % has to be from the original call notation. The 7th parameter is there % to check for this ";". \def\ccFunctionCall #1#2#3 #4(#5)#6;#7\end{% - \ccwFirst =\ccwFunctionFirst - \ccwSecond =\ccwFunctionSecond - \ccInitWidths + \ccInitFunctionWidths \def\xparam{#7}\ifx\xparam\empty \errmessage{Missing ";" at the end of the declaration. A method or function @@ -1209,9 +1214,7 @@ % has to be from the original call notation. The 4th parameter is there % to check for this ";". \def\ccVariableDeclaration #1#2 #3;#4\end{% - \ccwFirst =\ccwFunctionFirst - \ccwSecond =\ccwFunctionSecond - \ccInitWidths + \ccInitFunctionWidths \def\xparam{#4}\ifx\xparam\empty \errmessage{Missing ";" at the end of the declaration. A variable, typedef, or constant @@ -1245,9 +1248,7 @@ % o The 4th parameter contains an optional variable name. % The declaration has to be terminated with "\end". \def\ccEnumDeclaration #1#2\{#3\}#4\end {% - \ccwFirst =\ccwConstructorFirst - \ccwSecond =\ccwConstructorSecond - \ccInitWidths + \ccInitConstructorWidths \setbox\returntypebox=\hbox{}% \setbox\callnamebox=\hbox{\ccFont\ccPrintTokens #2\end}% \setbox\functioncallbox=\hbox{\ccFont @@ -1287,11 +1288,14 @@ \ifdim\wd\functioncallbox>\ccwSecondLong % Operators are assumed to fit in \ccwSecondLong. % Otherwise, they are formatted as functions. - \ccBool=\ccAlternateThreeColumn - \ifnum\ccBool=\ccTrue - \ccBool=\CCalternateThreeColumn + \ccBool=\ccLongParamLayout + \ifnum\ccBool=\ccFalse + \ccBool=\ccAlternateThreeColumn \ccInvert \fi - \ifnum\ccBool=\ccTrue + \ifnum\ccBool=\ccFalse + \ccBool=\CCalternateThreeColumn \ccInvert + \fi + \ifnum\ccBool=\ccFalse % Switches ext. format ON. {\setbox0=\hbox{\ccFont\unhcopy\callnamebox #1 }% @@ -1395,17 +1399,17 @@ \ccPrintTokens #2\end}}% \else \def\xparams{#1}\ifx\xparams\empty - \if#3&% + \ifx#3&% \ccSeparateFunctionXX{#2#3}#4\end% - \else\if#3*% + \else\ifx#3*% \ccSeparateFunctionXX{#2#3}#4\end% \else \ccSeparateFunctionXX{#2 }#3#4\end% \fi\fi \else - \if#3&% + \ifx#3&% \ccSeparateFunctionXX{#1#2#3}#4\end% - \else\if#3*% + \else\ifx#3*% \ccSeparateFunctionXX{#1#2#3}#4\end% \else \ccSeparateFunctionXX{#1#2 }#3#4\end% @@ -1471,10 +1475,10 @@ \def\ccPrintSingleTokenX #1#2\end{%CCtrue \ccPrintChar #1% - \def\xbody{\ccPrintSingleTokenX #2\end}% - \isEmpty{#2}\ifnum\ccBool=\ccTrue \let\xnext=\relax - \else\let\xnext=\xbody\fi - \xnext} + \def\xqabody{\ccPrintSingleTokenX #2\end}% + \isEmpty{#2}\ifnum\ccBool=\ccTrue \let\xqanext=\relax + \else\let\xqanext=\xqabody\fi + \xqanext} % Print C++ tokens (separated with spaces). Skip leading spaces. % The tokens have to be delimited by "\end". @@ -1486,14 +1490,14 @@ } \def\ccPrintTokensX #1#2\end{% \ccPrintChar #1% - \def\xbody{\ccPrintTokensX #2\end}% + \def\xqbody{\ccPrintTokensX #2\end}% \isEmpty{#2}\ifnum\ccBool=\ccTrue - \let\xnext=\relax + \let\xqnext=\relax \else \compareAndCopySpace{#2}#2\end - \let\xnext=\xbody + \let\xqnext=\xqbody \fi - \xnext} + \xqnext} % +-------------------------------------------------------------------------- @@ -1839,7 +1843,8 @@ \if,#2% \ifnum\nestinglevel=0 \advance\NParameters by1 - \ifnum\NParameters=1 \setbox\parameterX=% + \ifnum\NParameters=1 % + \setbox\parameterX=% \hbox{\ccPrintParameter #1const.&.\end}% \def\xxxbody{\ccExtractParamListX{}#3\end}% \else\advance\NParameters by1 @@ -1903,84 +1908,68 @@ % The parameter parsing macros counts the nesting level of % template parameter instantiations. \newcount\nestinglevel -\newcount\xnestinglevel % Print a parameter where "const ...&" pairs are eliminated. Strips a -% leading type that equals the \ccClassName. It is a four step process: -% 1. strip all in front of a "<" character. -% 2. extract the leading token without any space in it to decide, -% weather the type given is a templated type or not. -% 3. Compare the leading token with \ccClassName -% 4. If true, strip the possible following template parameter. +% type that equals the \ccPureClassName. It is a nested macro definition. +% It uses the \ccPureClassName to build a matching pattern to detect a +% possible type name to be eliminated. Similar solution as \ccReplacePrefix. +% If the function argument is empty, \ccEmptyParameter is printed. % The parameter has to be delimited with "<>\end". % Ignore leading spaces. -\def\ccPrintOwnClassParameter #1#2<#3#4\end{% +\def\ccPrintOwnClassParameter #1#2<>\end{% \ifnum\ccTagRmEigenClassName=\ccFalse - \ccPrintOwnClassXQX #1#2<#3#4\end% + \ccPrintTokens #1#2\end% \else - \ifx\ccPureTemplateParameters\empty - \if>#3% - \ccPrintOwnClassX #1#2 \end% no template case - \else - \ccPrintOwnClassXQX #1#2<#3#4\end% - \fi - \else\if>#3% - \ccPrintOwnClassX #1#2 \end% no template case + \ifx\ccPureClassName\empty + \ccPrintTokens #1#2\end% \else - \ccPrintOwnClassXX{#1#2}<#3#4\end% template case ? + \isEmpty{#2}\ifnum\ccBool=\ccTrue + \ccPrintTokens #1\end% A complete hack. Necessary to work together + % with the operator example. Otherwise a def is not working + % (totally obscure errormessage). However, I do not understand + % what is going on, I assume that the special case of a member + % function, where the first argument is \ccVar, causes the trouble. + % This special case is checked here. + \else + \edef\ccOwnClassPair{{\ccPureClassName}{#1#2\ccPureClassName}}% + \expandafter\ccPrintOwnClassParameterX\ccOwnClassPair \fi\fi \fi } -\def\ccPrintOwnClassXQX #1#2<>\end{% strip the unneccessary <> from the end - \ccPrintTokens #1#2\end} -\def\ccPrintOwnClassX #1 #2\end{% check for \ccClassName - \def\xparams{#1}\ifx\xparams\ccPureClassName - \isEmpty{#2}\ifnum\ccBool=\ccTrue - \ccEmptyParameter - \else - \ccPrintTokens #2\end% - \fi + +% Does the actual work: #1 is the \ccPureClassName +% #2 is the text to process with the \ccPureClassName +% appended at the end +\def\ccPrintOwnClassParameterX #1#2{% + % local macro to do the parsing: ##1 is the text before \ccPureClassName + % ##2 is the text after \ccPureClassName + \def\ccRepOwnClass ##1#1##2\end{% + \isEmpty{##2}\ifnum\ccBool=\ccTrue + % normal case, \ccPureClassName is not in the argument. + \ccPrintTokens ##1\end% \else - \ccPrintTokens #1 #2\end% - \fi} -\def\ccPrintOwnClassXX #1#2<>\end{% strip the unneccessary <> from the end - \ccPrintOwnClassXXX {#2}#1 \end} -\def\ccPrintOwnClassXXX #1#2 #3\end{% - % check \ccClassName in the possible template case - % #1 is the parameter tail starting with the template params - % #2 is the leading class name - % #3 is inbetween and should be empty - \def\qqparams{#3}\ifx\qqparams\empty - \def\xparams{#2}\ifx\xparams\ccPureClassName - \xnestinglevel=0 - \ccPrintOwnClassXXXX #1\end% strip the template parameters - \else - \ccPrintTokens #2#1\end% nothing stripped - \fi + % \ccPureClassName is in the argument. + \ccRepOwnClassX ##1##2\end% + \fi + }% + % local macro to remove the trailing \ccPureClassName. + % If the function argument is empty, print \ccEmptyParameter. + % ##1 is the text before \ccPureClassName + \def\ccRepOwnClassX ##1#1\end{% + \isEmpty{##1}\ifnum\ccBool=\ccTrue + \ccEmptyParameter \else - \ccPrintTokens #2\ \end - \ccPrintOwnClassXXX {#1}#3\end - \fi} -\def\ccPrintOwnClassXXXX #1#2\end{% strip a leading template parameter - \if<#1\advance\xnestinglevel by1 \fi - \if>#1\advance\xnestinglevel by-1 \fi - \ifnum\xnestinglevel=0 - \isEmpty{#2}\ifnum\ccBool=\ccTrue - \ccEmptyParameter - \else - \ccPrintTokens #2\end% - \fi - \let\xnext=\relax - \else - \def\xparams{#2}% - \ifx\xparams\empty - \errmessage{Mismatching angles in template - parameter list}% - \fi - \def\xbody{\ccPrintOwnClassXXXX #2\end}% - \let\xnext=\xbody - \fi - \xnext} + \ccPrintTokens ##1\end% \ccRepOwnClassXX was superfluous here. + \fi + }% + % local macro to remove leading spaces. + % ##1##2 is the (non empty) argument without leading spaces. + %\def\ccRepOwnClassXX ##1##2\end{% + % \ccPrintTokens ##1##2\end% + %}% + % apply the local macro + \ccRepOwnClass #2\end% +} % Print a C++ function or method parameter. Strips a matching