IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 9, 2004, 2:47:24 PM (22 years ago)
Author:
rhl
Message:

1/ Relaxed rule about always using parens
2/ Changed \XXX to \TBD (from panstarrs.def)
3/ Changed New/Del to Alloc/Free

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/misc/codeConventions.tex

    r138 r165  
    1717
    1818\newcommand{\matchBracket}[1]{}         % help emacs match properly
    19 \newcommand{\XXX}[1]{{\color{red} XXX #1\hfil\break}}
    2019
    2120\pagenumbering{roman} \thispagestyle{empty} \maketitle
     
    195194} psThing;
    196195
    197 psThing *psThingNew(int nthing);
    198 void psThingDel(psThing *thing);
     196psThing *psThingAlloc(int nthing);
     197void psThingFree(psThing *thing);
    199198
    200199#endif
     
    226225\subsubsection{SWIG Interface Files}
    227226
    228 \XXX{Write me}
     227\TBD{Write me}
    229228
    230229%------------------------------------------------------------------------------
     
    448447\label{DocComments}
    449448
    450 \XXX{Need references to Doxygen here.}
     449\TBD{Need references to Doxygen here.}
    451450
    452451If you need to give information about a type, interface, or variable
     
    555554describing what the function does.
    556555
    557 \XXX{Discuss Doxygen}
     556\TBD{Discuss Doxygen}
    558557
    559558\item The function's type should appear on the same line as the
     
    10061005problems. Even if the operator precedence seems clear to you, it might
    10071006not 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
     1007precedence as well as you do. In cases where the precedence rules
     1008are clear, the parentheses may be omitted.
     1009
     1010\begin{verbatim}
     1011if (a & b || c & d)                     // AVOID!
     1012if ((a & b) || (c & d))                 // RIGHT
    10131013\end{verbatim}
    10141014
     
    10831083Use \code{FIXME} to flag something that is bogus and broken.
    10841084
    1085 \XXX{Check Doxygen versions of these special comments. I could not
     1085\TBD{Check Doxygen versions of these special comments. I could not
    10861086find any occurrence of \code{@notused@} in the Doxygen documentation}
    1087 \item 
     1087\item
    10881088Use \code{NOTREACHED} to indicate a line of code that cannot be reached,
    10891089e.g.
     
    11091109\end{itemize}
    11101110
    1111 \subsubsection{\label{LNewDel}10.4.6     Constructors/Destructors}
     1111\subsubsection{\label{LAllocFree}10.4.6     Constructors/Destructors}
    11121112
    11131113Type definitions should always be accompanied by prototypes for
     
    11161116\begin{itemize}
    11171117\item  The constructor should consist of the type name followed by
    1118 \code{New}; e.g. a type \code{psImage} would
     1118\code{Alloc}; e.g. a type \code{psImage} would
    11191119be created by a function
    11201120\begin{verbatim}
    1121 psImage *psImageNew(int nrow, int ncol);
     1121psImage *psImageAlloc(int nrow, int ncol);
    11221122\end{verbatim}
    11231123
    11241124\item  Similarly, the type should be freed with a destructor named
    1125 \code{typeDel}, e.g.
    1126 \begin{verbatim}
    1127 void psImageDel(psImage *img);
     1125\code{typeFree}, e.g.
     1126\begin{verbatim}
     1127void psImageFree(psImage *img);
    11281128\end{verbatim}
    11291129
     
    11371137an error condition.
    11381138
     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
    11391142\end{itemize}
    11401143
     
    11421145
    11431146When defining a function to convert from one type to another, the
    1144 name should be of the form \code{psOldToNew}, e.g.\hfil\break
     1147name should be of the form \code{psOldToAlloc}, e.g.\hfil\break
    11451148\code{psEquatorialToEcliptic} (\emph{not} \code{psEquatorial2Ecliptic}).
    11461149
     
    11951198\label{SourceExample}
    11961199
    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}
    11981201Here's \file{psBuffer.h}:
    11991202\begin{verbatim}
     
    12071210} psBuffer;
    12081211
    1209 psBuffer *psBufferNew(void);
    1210 void psBufferDel(psBuffer *buf,         // buffer to delete
     1212psBuffer *psBufferAlloc(void);
     1213void psBufferFree(psBuffer *buf,         // buffer to delete
    12111214                 int deep);             // NOTUSED. Do a deep delete
    12121215
     
    12431246 * Create/destroy psBuffers
    12441247 */
    1245 psBuffer *psBufferNew(void)
     1248psBuffer *psBufferAlloc(void)
    12461249{
    12471250    psBuffer *buf = psAlloc(sizeof(psBuffer));
     
    12511254}
    12521255
    1253 void psBufferDel(psBuffer *buf,         // buffer to delete
     1256void psBufferFree(psBuffer *buf,         // buffer to delete
    12541257                 int deep)              // NOTUSED. Do a deep delete
    12551258{
     
    12911294int main(void)
    12921295{
    1293     buf = psBufferNew();
     1296    buf = psBufferAlloc();
    12941297    long t;                               // current time
    12951298
     
    13051308    psBufferAppend(buf, getNewline(NL));
    13061309
    1307     psBufferDel(buf, 0);
     1310    psBufferFree(buf, 0);
    13081311
    13091312    return 0;
     
    14021405  The line-length limit has been changed from 80 to 110 characters.
    14031406
     1407\item
     1408  Relaxed wording to allow parentheses to be omitted when the precedence
     1409  is well known and unambiguous.
     1410
    14041411\end{itemize}
    14051412
Note: See TracChangeset for help on using the changeset viewer.