summaryrefslogtreecommitdiff
path: root/doc/MaintGuide/Style.tex
blob: 14d080d26f7214978a74acf286b57f0e96400cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
% /*@@
%   @file      Style.tex
%   @date      Wed Jan 12 15:01:09 2000
%   @author    Tom Goodale
%   @desc 
%   
%   @enddesc 
%   @version $Header$
% @@*/
\begin{cactuspart}{1}{Philosphy and Style}{$RCSfile$}{$Revision$}
\renewcommand{\thepage}{\Alph{part}\arabic{page}}

\chapter{Philosophy} 

\begin{itemize}
\item
Portable
\item
Extensable
\item
Modular
\end{itemize}

\chapter{Coding Style}

The flesh has been written with the following coding guidelines...


\section{Indentation}

Two spaces, no tabs.

Two spaces are enough to clearly indent, more would be a waste of
space, less not really noticeable.

\section{Brace positioning}

Each opening brace should appear on a line by itself,
aligned with the preceeding statement.

Closing braces should line up with the corresponding
opening brace, and should be on lines by themselves
apart from the {\tt while} in a 
%
\begin{verbatim}
do
{

...

} while(...);

\end{verbatim}
%
statement.

This brace positioning stategy makes it easy to run ones eye from a closing
or opening brace to its matching opening or closing brace.

Braces should be used for all {\tt if} and {\tt for} statements.

\section{GRDOC}

All files should start with a grdoc header, and all functions
should have grdoc headers.

The file grdoc should contain a description of the contents of the file
and an \@version with the CVS \$Header\$ tag.

The function grdoc should contain

\begin{itemize}
\item
a description of the function, saying what it does.
\item
all function arguments with descriptions
of what they are and what they are used for.
\item
the return codes should be described.
\end{itemize}

After the first actual release the history should be filled
in with each change.

\section{Header Files}

Header files should not include any system header file, but should
contain in the initial comment a list of system header files which
are assumed to have been included before this file is included.

The body of a header should be protected against multiple inclusion
by lines of the form

\begin{verbatim}
#ifndef _NAMEOFHEADERFILEINCAPITALS_H_
#define _NAMEOFHEADERFILEINCAPITALS_H_

...body of header file...

#endif /* _NAMEOFHEADERFILEINCAPITALS_H_ */

\end{verbatim}

Function prototypes in header files should be protected
against C++ linkage by

\begin{verbatim}
#ifdef __cplusplus
extern "C" 
{
#endif

...prototypes...

#ifdef __cplusplus
}
#endif
\end{verbatim}

The Cactus header files ({\tt cctk\_<name>}) should only include
information relevant for thorn programmers. 

\section{Source Files}

Source files should have as their first line under the 
grdoc header a line containing

%\begin{verbatim}
\vskip .3cm
{\bf static char \*rcsid = "\$Header\$"; }
%\end{verbatim}
\vskip .3cm
or the expanded rcs version of this.

Globally visable functions should appear before local
functions.

(NOTE: currently the schedule stuff is a good example of
what I'm coming to like as a style, e.g.
src/main/ScheduleInterface.c )

\section{Naming Conventions}

All functions which may be used by thorns should have names beginning
with {\tt CCTK\_} and then capitalised words with no underscores.

All functions used internally by the flesh should have names beginning with
{\tt CCTKi\_} and then capitalised words with no underscores.

Header files to be included by thorns should have names beginning with
{\tt cctk\_}.

Structures which may be used by thorns should have names beginning with
{\tt c} and then capitalised words, {\it e.g.} {\tt cGroup}. The 
exception here is structures associated with utility routines which
are not Cactus specific, there the structure names should start with a
{\tt t\_}. 

Structures which are purely internal to the flesh should have
names beginning with {\tt i}.

All Cactus sourcefile names (except general utility files) should 
use capitilised words without underscores.




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{cactuspart}