mirror of https://github.com/CGAL/cgal
Parameter lists are now correct separated.
Matching const ... & pairs are eliminated from parameters. A leading classname is eliminated from a parameter.
This commit is contained in:
parent
4f52196c78
commit
cab523f0f8
|
|
@ -5,8 +5,10 @@
|
|||
% $Date$
|
||||
% ----------------------------------------
|
||||
|
||||
% \tracingmacros=1
|
||||
\newcount\spaceflag
|
||||
\tracingmacros=1
|
||||
\newcount\nestinglevel % counts nesting levels of template parameters
|
||||
\newcount\xnestinglevel % counts nesting levels of template parameters
|
||||
\newcount\spaceflag % result, weather a parameter starts with a space
|
||||
|
||||
% These macros allow the characterwise parsing of an argument, where normally
|
||||
% the spaces are ignored.
|
||||
|
|
@ -21,7 +23,7 @@
|
|||
\def\xxparams{#1}\def\xxxparams{#2#3}\ifx\xxparams\xxxparams\spaceflag=0
|
||||
\else\spaceflag=1 \fi}
|
||||
\def\testAndCopySpace #1{%
|
||||
\compareAndCopySpace{#1}#1\end}
|
||||
\def\qparams{#1}\ifx\qparams\empty\else\compareAndCopySpace{#1}#1\end\fi}
|
||||
\def\compareAndCopySpace #1#2#3\end{%
|
||||
\def\xxparams{#1}\def\xxxparams{#2#3}\ifx\xxparams\xxxparams\else\ \fi}
|
||||
|
||||
|
|
@ -48,7 +50,7 @@
|
|||
\label{#1}}
|
||||
|
||||
\def\creationvariable #1{\creation #1}
|
||||
\def\threecolumns #1 #2 {\typewidth=#1 % compare to setopdims
|
||||
\def\threecolumns #1#2{\typewidth=#1 % compare to setopdims
|
||||
\callwidth=#2
|
||||
\descriptwidth=\textwidth
|
||||
\advance\descriptwidth-\typewidth
|
||||
|
|
@ -90,60 +92,131 @@
|
|||
% Print one parameter in C++ style (including spaces).
|
||||
\def\CCstyle #1{{\em \CCprintTokens #1 ;\/}}
|
||||
|
||||
% Print a parameter where "const ...&" pairs are eliminated. Strips a
|
||||
% leading type that equals the \classname. It is a three 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 \classname
|
||||
% 4. If true, strip the possible following template parameter.
|
||||
% The parameter has to be delimited with "<>;".
|
||||
% Ignore leading spaces.
|
||||
\def\CCprintOwnClassParameter #1#2<#3#4;{%
|
||||
\if>#3%
|
||||
\CCprintOwnClassX #1#2 ;% no template case
|
||||
\else
|
||||
\CCprintOwnClassXX{#1#2}<#3#4;% template case ?
|
||||
\fi}
|
||||
\def\CCprintOwnClassX #1 #2;{% check for \classname
|
||||
\def\xparams{#1}\ifx\xparams\pureclassname
|
||||
\CCprintTokens #2;%
|
||||
\else
|
||||
\CCprintTokens #1 #2;%
|
||||
\fi}
|
||||
\def\CCprintOwnClassXX #1#2<>;{% strip the unneccessary <> from the end
|
||||
\CCprintOwnClassXXX {#2}#1 ;}
|
||||
\def\CCprintOwnClassXXX #1#2 #3;{%
|
||||
% check \classname 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\pureclassname
|
||||
\xnestinglevel=0
|
||||
\CCprintOwnClassXXXX #1;% strip the template parameters
|
||||
\else
|
||||
\CCprintTokens #2#1 ;% nothing stripped
|
||||
\fi
|
||||
\else
|
||||
\errhelp{The allowed syntax is: name< params...}%
|
||||
\errmessage{Confusing class name with a space before
|
||||
the template parameters.}%
|
||||
\fi}
|
||||
\def\CCprintOwnClassXXXX #1#2;{% strip a leading template parameter
|
||||
\if<#1\advance\xnestinglevel by1 \fi
|
||||
\if>#1\advance\xnestinglevel by-1 \fi
|
||||
\ifnum\xnestinglevel=0
|
||||
\CCprintTokens #2 ;%
|
||||
\let\xnext=\relax
|
||||
\else
|
||||
\def\xparams{#2}%
|
||||
\ifx\xparams\empty
|
||||
\errhelp{Look for mismatching angles.}%
|
||||
\errmessage{Mismatching angles in template
|
||||
parameter list.}%
|
||||
\fi
|
||||
\def\xbody{\CCprintOwnClassXXXX #2;}%
|
||||
\let\xnext=\xbody
|
||||
\fi
|
||||
\xnext}
|
||||
|
||||
|
||||
|
||||
% Print a C++ function or method parameter. Strips a matching
|
||||
% "const ...&" pair.
|
||||
% The parameter has to be delimited with "const.&.;".
|
||||
\def\CCprintParameter #1const#2#3#5;{%
|
||||
\if.#2\CCprintOwnClassParameter #1<>;%
|
||||
\else
|
||||
\if\CCprintParameter #1#3#5;%
|
||||
\else
|
||||
\CCprintParameter #1#2#3 #4#5;%
|
||||
\fi
|
||||
\fi}
|
||||
|
||||
% Print a C++ parameter list (separated with commatas). The output formats
|
||||
% with a space in front of the parameter text.
|
||||
% with a space between commata and the parameter text.
|
||||
\def\CCprintParamList #1{%
|
||||
\nestinglevel=0
|
||||
\CCprintParamListX{}#1;}
|
||||
% Support function:
|
||||
% o The first parameter accumulates the so far parsed first parameter.
|
||||
% o The second parameter contains the current nesting level. Start with 0.
|
||||
% o The third parameter contains the next character.
|
||||
% o The fourth parameter contains the rest.
|
||||
% o The second parameter contains the next character.
|
||||
% o The third parameter contains the rest.
|
||||
% The parsing process iterates characterwise.
|
||||
% The parameter list has to be terminated with ";".
|
||||
\newcount\nestinglevel
|
||||
\def\CCprintParamList #1#2#3#4;{%
|
||||
\def\xxparams{#4}%
|
||||
\nestinglevel=#2%
|
||||
% \edef\spaceflag{\testSpace{#4}}%
|
||||
\testSpace{#4}%
|
||||
\if<#3\advance\nestinglevel by1\fi
|
||||
\if>#3\advance\nestinglevel by-1\fi
|
||||
\if,#3%
|
||||
\ifnum\nestinglevel=0%
|
||||
\CCprintTokens #1 ;,\ %
|
||||
\def\xxbody{\CCprintParamList{}{0}#4;}%
|
||||
\else\ifnum\nestinglevel<0%
|
||||
\def\CCprintParamListX #1#2#3;{%
|
||||
\testSpace{#3}%
|
||||
\if<#2\advance\nestinglevel by1 \fi
|
||||
\if>#2\advance\nestinglevel by-1 \fi
|
||||
\if,#2%
|
||||
\ifnum\nestinglevel=0
|
||||
\CCprintParameter #1const.&.;,\ %
|
||||
\def\xxbody{\CCprintParamListX{}#3;}%
|
||||
\else\ifnum\nestinglevel<0
|
||||
\def\errhelp{Look for unbalanced angles in
|
||||
template types in the C++ parameter list.}%
|
||||
\errmessage{Unbalanced angles detected.}%
|
||||
\def\xxbody{\CCprintParamList{}{0}#4;}%
|
||||
\def\xxbody{\CCprintParamListX{}#3;}%
|
||||
\else% comma within template parameter detected
|
||||
\ifnum\spaceflag=1
|
||||
\def\xxbody{\CCprintParamList
|
||||
{#1#3 }{\nestinglevel}#4;}%
|
||||
\def\xxbody{\CCprintParamListX
|
||||
{#1#2 }#3;}%
|
||||
\else
|
||||
\def\xxbody{\CCprintParamList
|
||||
{#1#3}{\nestinglevel}#4;}%
|
||||
\def\xxbody{\CCprintParamListX
|
||||
{#1#2}#3;}%
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
\else\ifx\xxparams\empty%
|
||||
\ifnum\nestinglevel=0%
|
||||
\CCprintTokens #1#3 ;%
|
||||
\else\def\xxparams{#3}\ifx\xxparams\empty%
|
||||
\ifnum\nestinglevel=0
|
||||
\CCprintParameter #1#2const.&.;%
|
||||
\else\def\errhelp{Look for unbalanced angles in
|
||||
template types in the C++ parameter list.}%
|
||||
\errmessage{Unbalanced angles detected.}%
|
||||
\fi
|
||||
\def\xxbody{\CCprintParamList{}{0}#4;}%
|
||||
\def\xxbody{\CCprintParamListX{}#3;}%
|
||||
\else
|
||||
\ifnum\spaceflag=1
|
||||
\def\xxbody{\CCprintParamList
|
||||
{#1#3 }{\nestinglevel}#4;}%
|
||||
\def\xxbody{\CCprintParamListX
|
||||
{#1#2 }#3;}%
|
||||
\else
|
||||
\def\xxbody{\CCprintParamList
|
||||
{#1#3}{\nestinglevel}#4;}%
|
||||
\def\xxbody{\CCprintParamListX
|
||||
{#1#2}#3;}%
|
||||
\fi
|
||||
\fi
|
||||
\fi
|
||||
\ifx\xxparams\empty\let\xxnext=\relax
|
||||
\def\xxparams{#3}\ifx\xxparams\empty\let\xxnext=\relax
|
||||
\else\let\xxnext=\xxbody\fi
|
||||
\xxnext}
|
||||
|
||||
|
|
@ -152,9 +225,9 @@
|
|||
\def\params{#2}\ifx\params\empty%
|
||||
\mbox{\classtemplatename\ \ \var;}%
|
||||
\else\mbox{\classtemplatename
|
||||
\ \ \var{\em (\CCprintParamList{}{0}#2;);}}%
|
||||
\ \ \var{\em (\CCprintParamList{#2});}}%
|
||||
\fi\par }
|
||||
\def\constructor #1 #2 {%
|
||||
\def\constructor #1#2{%
|
||||
\constructorcall #1 \par
|
||||
\hspace*{1cm}\hfill
|
||||
\parbox[t]{\createtextwidth}{\sloppy #2}\par
|
||||
|
|
@ -173,26 +246,42 @@
|
|||
\ifx\params\empty \CCprintSingleToken #1;%
|
||||
\else\extractname #2;\fi}
|
||||
|
||||
\def\methodcall #1 #2(#3)#4; #5; {%
|
||||
% Formats a method or a function call.
|
||||
% o The first parameter contains a 0 for a method call, a 1 for a function.
|
||||
% o The second parameter contains the beginning of the type declaration.
|
||||
% o The third parameter contains the rest of the type and the function name.
|
||||
% o The fourth parameter contains the parameter list (maybe empty).
|
||||
% o The fifth parameter contains the optional const specifier for methods.
|
||||
% The declaration has to be terminated with ";;\end" where the first ";"
|
||||
% has to be from the original call notation. The sixth parameter is there
|
||||
% to check for this ";".
|
||||
\def\functioncall #1#2 #3(#4)#5;#6\end{%
|
||||
\def\xparam{#6}\ifx\xparam\empty\def\errhelp{A method
|
||||
or function declaration has to end with a ";".}%
|
||||
\errmessage{Missing ";" at the end of the
|
||||
declaration. Go ahead, I've inserted one.}%
|
||||
\fi
|
||||
\parbox[t]{\typewidth}{\sloppy
|
||||
{\em \extracttype {#1}#2 ;}}
|
||||
{\em \extracttype {#2}#3 ;}}
|
||||
\setbox0=\hbox{\mbox{
|
||||
#5{\em \extractname #2 ;%
|
||||
(\def\params{#3}\ifx\params\empty\else%
|
||||
\CCprintParamList{}{0}#3;\fi)}
|
||||
\ifnum#1=0 \var.\fi{\em \extractname #3 ;%
|
||||
(\def\params{#4}\ifx\params\empty\else%
|
||||
\CCprintParamList{#4}\fi)}
|
||||
}}
|
||||
\ifdim\wd0>\callwidth
|
||||
\parbox[t]{\callwidthl}{\box0}\hfill\par
|
||||
\hspace*{1cm}\hfill
|
||||
\else\parbox[t]{\callwidth}{\box0}\hfill
|
||||
\fi}
|
||||
\def\method #1 #2 {\smallskip
|
||||
\methodcall #1; \var.;
|
||||
\def\method #1#2{%
|
||||
\smallskip
|
||||
\functioncall{0}#1;\end
|
||||
\parbox[t]{\descriptwidth}{\sloppy #2}\hfill\par
|
||||
\smallskip}
|
||||
|
||||
\def\function #1 #2 {\smallskip
|
||||
\methodcall #1; ;
|
||||
\def\function #1#2{%
|
||||
\smallskip
|
||||
\functioncall{1}#1;\end
|
||||
\parbox[t]{\descriptwidth}{\sloppy #2}\hfill\par
|
||||
\smallskip}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue