Changeset 165 for trunk/doc/misc/codeConventions.tex
- Timestamp:
- Mar 9, 2004, 2:47:24 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/misc/codeConventions.tex (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/misc/codeConventions.tex
r138 r165 17 17 18 18 \newcommand{\matchBracket}[1]{} % help emacs match properly 19 \newcommand{\XXX}[1]{{\color{red} XXX #1\hfil\break}}20 19 21 20 \pagenumbering{roman} \thispagestyle{empty} \maketitle … … 195 194 } psThing; 196 195 197 psThing *psThing New(int nthing);198 void psThing Del(psThing *thing);196 psThing *psThingAlloc(int nthing); 197 void psThingFree(psThing *thing); 199 198 200 199 #endif … … 226 225 \subsubsection{SWIG Interface Files} 227 226 228 \ XXX{Write me}227 \TBD{Write me} 229 228 230 229 %------------------------------------------------------------------------------ … … 448 447 \label{DocComments} 449 448 450 \ XXX{Need references to Doxygen here.}449 \TBD{Need references to Doxygen here.} 451 450 452 451 If you need to give information about a type, interface, or variable … … 555 554 describing what the function does. 556 555 557 \ XXX{Discuss Doxygen}556 \TBD{Discuss Doxygen} 558 557 559 558 \item The function's type should appear on the same line as the … … 1006 1005 problems. Even if the operator precedence seems clear to you, it might 1007 1006 not be to others-you shouldn't assume that other programmers know 1008 precedence as well as you do. 1009 1010 \begin{verbatim} 1011 if (a == b && c == d) // AVOID! 1012 if ((a == b) && (c == d)) // RIGHT 1007 precedence as well as you do. In cases where the precedence rules 1008 are clear, the parentheses may be omitted. 1009 1010 \begin{verbatim} 1011 if (a & b || c & d) // AVOID! 1012 if ((a & b) || (c & d)) // RIGHT 1013 1013 \end{verbatim} 1014 1014 … … 1083 1083 Use \code{FIXME} to flag something that is bogus and broken. 1084 1084 1085 \ XXX{Check Doxygen versions of these special comments. I could not1085 \TBD{Check Doxygen versions of these special comments. I could not 1086 1086 find any occurrence of \code{@notused@} in the Doxygen documentation} 1087 \item 1087 \item 1088 1088 Use \code{NOTREACHED} to indicate a line of code that cannot be reached, 1089 1089 e.g. … … 1109 1109 \end{itemize} 1110 1110 1111 \subsubsection{\label{L NewDel}10.4.6 Constructors/Destructors}1111 \subsubsection{\label{LAllocFree}10.4.6 Constructors/Destructors} 1112 1112 1113 1113 Type definitions should always be accompanied by prototypes for … … 1116 1116 \begin{itemize} 1117 1117 \item The constructor should consist of the type name followed by 1118 \code{ New}; e.g. a type \code{psImage} would1118 \code{Alloc}; e.g. a type \code{psImage} would 1119 1119 be created by a function 1120 1120 \begin{verbatim} 1121 psImage *psImage New(int nrow, int ncol);1121 psImage *psImageAlloc(int nrow, int ncol); 1122 1122 \end{verbatim} 1123 1123 1124 1124 \item Similarly, the type should be freed with a destructor named 1125 \code{type Del}, e.g.1126 \begin{verbatim} 1127 void psImage Del(psImage *img);1125 \code{typeFree}, e.g. 1126 \begin{verbatim} 1127 void psImageFree(psImage *img); 1128 1128 \end{verbatim} 1129 1129 … … 1137 1137 an error condition. 1138 1138 1139 \item The destructor should call \code{psMemGetRefCounter}; if the value is greater 1140 than one, the destructor should simply call \code{psMemDecrRefCounter} and return. 1141 1139 1142 \end{itemize} 1140 1143 … … 1142 1145 1143 1146 When defining a function to convert from one type to another, the 1144 name should be of the form \code{psOldTo New}, e.g.\hfil\break1147 name should be of the form \code{psOldToAlloc}, e.g.\hfil\break 1145 1148 \code{psEquatorialToEcliptic} (\emph{not} \code{psEquatorial2Ecliptic}). 1146 1149 … … 1195 1198 \label{SourceExample} 1196 1199 1197 \ XXX{Need to include more of the rules, and shorten the example}1200 \TBD{Need to include more of the rules, and shorten the example} 1198 1201 Here's \file{psBuffer.h}: 1199 1202 \begin{verbatim} … … 1207 1210 } psBuffer; 1208 1211 1209 psBuffer *psBuffer New(void);1210 void psBuffer Del(psBuffer *buf, // buffer to delete1212 psBuffer *psBufferAlloc(void); 1213 void psBufferFree(psBuffer *buf, // buffer to delete 1211 1214 int deep); // NOTUSED. Do a deep delete 1212 1215 … … 1243 1246 * Create/destroy psBuffers 1244 1247 */ 1245 psBuffer *psBuffer New(void)1248 psBuffer *psBufferAlloc(void) 1246 1249 { 1247 1250 psBuffer *buf = psAlloc(sizeof(psBuffer)); … … 1251 1254 } 1252 1255 1253 void psBuffer Del(psBuffer *buf, // buffer to delete1256 void psBufferFree(psBuffer *buf, // buffer to delete 1254 1257 int deep) // NOTUSED. Do a deep delete 1255 1258 { … … 1291 1294 int main(void) 1292 1295 { 1293 buf = psBuffer New();1296 buf = psBufferAlloc(); 1294 1297 long t; // current time 1295 1298 … … 1305 1308 psBufferAppend(buf, getNewline(NL)); 1306 1309 1307 psBuffer Del(buf, 0);1310 psBufferFree(buf, 0); 1308 1311 1309 1312 return 0; … … 1402 1405 The line-length limit has been changed from 80 to 110 characters. 1403 1406 1407 \item 1408 Relaxed wording to allow parentheses to be omitted when the precedence 1409 is well known and unambiguous. 1410 1404 1411 \end{itemize} 1405 1412
Note:
See TracChangeset
for help on using the changeset viewer.
