VirtualBox

Changeset 68445 in vbox


Ignore:
Timestamp:
Aug 17, 2017 1:27:05 PM (7 years ago)
Author:
vboxsync
Message:

doc/VBox-CodingGuideslines: use <li> instead of '-' as doxygen expects no blank line between such list items and added another example of code to avoid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/VBox-CodingGuidelines.cpp

    r63292 r68445  
    2929 * @section sec_vbox_guideline_compulsory       Compulsory
    3030 *
    31  *
    32  *      - The indentation size is 4 chars.
    33  *
    34  *      - Tabs are only ever used in makefiles.
    35  *
    36  *      - Use RT and VBOX types.
    37  *
    38  *      - Use Runtime functions.
    39  *
    40  *      - Use the standard bool, uintptr_t, intptr_t and [u]int[1-9+]_t types.
    41  *
    42  *      - Avoid using plain unsigned and int.
    43  *
    44  *      - Use static wherever possible. This makes the namespace less polluted
     31 * <ul>
     32 *
     33 *   <li> The indentation size is 4 chars.
     34 *
     35 *   <li> Tabs are only ever used in makefiles.
     36 *
     37 *   <li> Use RT and VBOX types.
     38 *
     39 *   <li> Use Runtime functions.
     40 *
     41 *   <li> Use the standard bool, uintptr_t, intptr_t and [u]int[1-9+]_t types.
     42 *
     43 *   <li> Avoid using plain unsigned and int.
     44 *
     45 *   <li> Use static wherever possible. This makes the namespace less polluted
    4546 *        and avoids nasty name clash problems which can occur, especially on
    4647 *        Unix-like systems. (1)  It also simplifies locating callers when
    4748 *        changing it (single source file vs entire VBox tree).
    4849 *
    49  *      - Public names are of the form Domain[Subdomain[]]Method, using mixed
     50 *   <li> Public names are of the form Domain[Subdomain[]]Method, using mixed
    5051 *        casing to mark the words. The main domain is all uppercase.
    5152 *        (Think like java, mapping domain and subdomain to packages/classes.)
    5253 *
    53  *      - Public names are always declared using the appropriate DECL macro. (2)
    54  *
    55  *      - Internal names starts with a lowercased main domain.
    56  *
    57  *      - Defines are all uppercase and separate words with underscore.
     54 *   <li> Public names are always declared using the appropriate DECL macro. (2)
     55 *
     56 *   <li> Internal names starts with a lowercased main domain.
     57 *
     58 *   <li> Defines are all uppercase and separate words with underscore.
    5859 *        This applies to enum values too.
    5960 *
    60  *      - Typedefs are all uppercase and contain no underscores to distinguish
     61 *   <li> Typedefs are all uppercase and contain no underscores to distinguish
    6162 *        them from defines.
    6263 *
    63  *      - Pointer typedefs start with 'P'. If pointer to const then 'PC'.
    64  *
    65  *      - Function typedefs start with 'FN'. If pointer to FN then 'PFN'.
    66  *
    67  *      - All files are case sensitive.
    68  *
    69  *      - Slashes are unix slashes ('/') runtime converts when necessary.
    70  *
    71  *      - char strings are UTF-8.
    72  *
    73  *      - Strings from any external source must be treated with utmost care as
     64 *   <li> Pointer typedefs start with 'P'. If pointer to const then 'PC'.
     65 *
     66 *   <li> Function typedefs start with 'FN'. If pointer to FN then 'PFN'.
     67 *
     68 *   <li> All files are case sensitive.
     69 *
     70 *   <li> Slashes are unix slashes ('/') runtime converts when necessary.
     71 *
     72 *   <li> char strings are UTF-8.
     73 *
     74 *   <li> Strings from any external source must be treated with utmost care as
    7475 *        they do not have to be valid UTF-8.  Only trust internal strings.
    7576 *
    76  *      - All functions return VBox status codes. There are three general
     77 *   <li> All functions return VBox status codes. There are three general
    7778 *        exceptions from this:
    78  *              -# Predicate functions. These are function which are boolean in
     79 *
     80 *       <ol>
     81 *             <li>Predicate functions. These are function which are boolean in
    7982 *                 nature and usage. They return bool. The function name will
    8083 *                 include 'Has', 'Is' or similar.
    81  *              -# Functions which by nature cannot possibly fail.
     84 *             <li>Functions which by nature cannot possibly fail.
    8285 *                 These return void.
    83  *              -# "Get"-functions which return what they ask for.
     86 *             <li>"Get"-functions which return what they ask for.
    8487 *                 A get function becomes a "Query" function if there is any
    8588 *                 doubt about getting what is ask for.
    86  *
    87  *      - VBox status codes have three subdivisions:
    88  *              -# Errors, which are VERR_ prefixed and negative.
    89  *              -# Warnings, which are VWRN_ prefixed and positive.
    90  *              -# Informational, which are VINF_ prefixed and positive.
    91  *
    92  *      - Platform/OS operation are generalized and put in the IPRT.
    93  *
    94  *      - Other useful constructs are also put in the IPRT.
    95  *
    96  *      - The code shall not cause compiler warnings. Check this on ALL
     89 *       </ol>
     90 *
     91 *   <li> VBox status codes have three subdivisions:
     92 *         <ol>
     93 *           <li> Errors, which are VERR_ prefixed and negative.
     94 *           <li> Warnings, which are VWRN_ prefixed and positive.
     95 *           <li> Informational, which are VINF_ prefixed and positive.
     96 *        </ol>
     97 *
     98 *   <li> Platform/OS operation are generalized and put in the IPRT.
     99 *
     100 *   <li> Other useful constructs are also put in the IPRT.
     101 *
     102 *   <li> The code shall not cause compiler warnings. Check this on ALL
    97103 *        the platforms.
    98104 *
    99  *      - The use of symbols leading with single or double underscores is
     105 *   <li> The use of symbols leading with single or double underscores is
    100106 *        forbidden as that intrudes on reserved compiler/system namespace. (3)
    101107 *
    102  *      - All files have file headers with $Id and a file tag which describes
     108 *   <li> All files have file headers with $Id and a file tag which describes
    103109 *        the file in a sentence or two.
    104110 *        Note: Use the svn-ps.cmd/svn-ps.sh utility with the -a option to add
     
    106112 *              configured.
    107113 *
    108  *      - All public functions are fully documented in Doxygen style using the
     114 *   <li> All public functions are fully documented in Doxygen style using the
    109115 *        javadoc dialect (using the 'at' instead of the 'slash' as
    110116 *        commandprefix.)
    111117 *
    112  *      - All structures in header files are described, including all their
     118 *   <li> All structures in header files are described, including all their
    113119 *        members. (Doxygen style, of course.)
    114120 *
    115  *      - All modules have a documentation '\@page' in the main source file
     121 *   <li> All modules have a documentation '\@page' in the main source file
    116122 *        which describes the intent and actual implementation.
    117123 *
    118  *      - Code which is doing things that are not immediately comprehensible
     124 *   <li> Code which is doing things that are not immediately comprehensible
    119125 *        shall include explanatory comments.
    120126 *
    121  *      - Documentation and comments are kept up to date.
    122  *
    123  *      - Headers in /include/VBox shall not contain any slash-slash C++
     127 *   <li> Documentation and comments are kept up to date.
     128 *
     129 *   <li> Headers in /include/VBox shall not contain any slash-slash C++
    124130 *        comments, only ANSI C comments!
    125131 *
    126  *      - Comments on \#else indicates what begins while the comment on a
     132 *   <li> Comments on \#else indicates what begins while the comment on a
    127133 *        \#endif indicates what ended.  Only add these when there are more than
    128134 *        a few lines (6-10) of \#ifdef'ed code, otherwise they're just clutter.
    129  *
     135 * </ul>
    130136 *
    131137 * (1) It is common practice on Unix to have a single symbol namespace for an
     
    150156 * Some facts first:
    151157 *
    152  *      - On 64-bit Windows the type long remains 32-bit. On nearly all other
     158 * <ul>
     159 *
     160 *   <li> On 64-bit Windows the type long remains 32-bit. On nearly all other
    153161 *        64-bit platforms long is 64-bit.
    154162 *
    155  *      - On all 64-bit platforms we care about, int is 32-bit, short is 16 bit
     163 *   <li> On all 64-bit platforms we care about, int is 32-bit, short is 16 bit
    156164 *        and char is 8-bit.
    157165 *        (I don't know about any platforms yet where this isn't true.)
    158166 *
    159  *      - size_t, ssize_t, uintptr_t, ptrdiff_t and similar are all 64-bit on
     167 *   <li> size_t, ssize_t, uintptr_t, ptrdiff_t and similar are all 64-bit on
    160168 *        64-bit platforms. (These are 32-bit on 32-bit platforms.)
    161169 *
    162  *      - There is no inline assembly support in the 64-bit Microsoft compilers.
    163  *
     170 *   <li> There is no inline assembly support in the 64-bit Microsoft compilers.
     171 *
     172 * </ul>
    164173 *
    165174 * Now for the guidelines:
    166175 *
    167  *      - Never, ever, use int, long, ULONG, LONG, DWORD or similar to cast a
     176 * <ul>
     177 *
     178 *   <li> Never, ever, use int, long, ULONG, LONG, DWORD or similar to cast a
    168179 *        pointer to integer.  Use uintptr_t or intptr_t. If you have to use
    169180 *        NT/Windows types, there is the choice of ULONG_PTR and DWORD_PTR.
    170181 *
    171  *      - Avoid where ever possible the use of the types 'long' and 'unsigned
     182 *   <li> Avoid where ever possible the use of the types 'long' and 'unsigned
    172183 *        long' as these differs in size between windows and the other hosts
    173184 *        (see above).
    174185 *
    175  *      - RT_OS_WINDOWS is defined to indicate Windows. Do not use __WIN32__,
     186 *   <li> RT_OS_WINDOWS is defined to indicate Windows. Do not use __WIN32__,
    176187 *        __WIN64__ and __WIN__ because they are all deprecated and scheduled
    177188 *        for removal (if not removed already). Do not use the compiler
     
    194205 *        @endcode
    195206 *
    196  *      - There are RT_OS_xxx defines for each OS, just like RT_OS_WINDOWS
     207 *   <li> There are RT_OS_xxx defines for each OS, just like RT_OS_WINDOWS
    197208 *        mentioned above. Use these defines instead of any predefined
    198209 *        compiler stuff or defines from system headers.
    199210 *
    200  *      - RT_ARCH_X86 is defined when compiling for the x86 the architecture.
     211 *   <li> RT_ARCH_X86 is defined when compiling for the x86 the architecture.
    201212 *        Do not use __x86__, __X86__, __[Ii]386__, __[Ii]586__, or similar
    202213 *        for this purpose.
    203214 *
    204  *      - RT_ARCH_AMD64 is defined when compiling for the AMD64 architecture.
     215 *   <li> RT_ARCH_AMD64 is defined when compiling for the AMD64 architecture.
    205216 *        Do not use __AMD64__, __amd64__ or __x64_86__.
    206217 *
    207  *      - Take care and use size_t when you have to, esp. when passing a pointer
     218 *   <li> Take care and use size_t when you have to, esp. when passing a pointer
    208219 *        to a size_t as a parameter.
    209220 *
    210  *      - Be wary of type promotion to (signed) integer. For example the
     221 *   <li> Be wary of type promotion to (signed) integer. For example the
    211222 *        following will cause u8 to be promoted to int in the shift, and then
    212223 *        sign extended in the assignment 64-bit:
     
    217228 *        @endcode
    218229 *
     230 * </ul>
    219231 *
    220232 * @subsection sec_vbox_guideline_compulsory_cppmain   C++ guidelines for Main
     
    224236 * instead of more for the following reasons:
    225237 *
    226  *  -  Template code is harder to read and understand. Custom templates create
    227  *     territories which only the code writer understands.
    228  *
    229  *  -  Errors in using templates create terrible C++ compiler messages.
    230  *
    231  *  -  Template code is really hard to look at in a debugger.
    232  *
    233  *  -  Templates slow down the compiler a lot.
    234  *
    235  *  In particular, the following bits should be considered deprecated and should
    236  *  NOT be used in new code:
    237  *
    238  *  -  everything in include/iprt/cpputils.h (auto_ref_ptr, exception_trap_base,
    239  *     char_auto_ptr and friends)
    240  *
    241  *  Generally, in many cases, a simple class with a proper destructor can achieve
    242  *  the same effect as a 1,000-line template include file, and the code is
    243  *  much more accessible that way.
    244  *
    245  *  Using standard STL templates like std::list, std::vector and std::map is OK.
    246  *  Exceptions are:
    247  *
    248  *  -  Guest Additions because we don't want to link against libstdc++ there.
    249  *
    250  *  -  std::string should not be used because we have iprt::MiniString and
     238 * <ul>
     239 *
     240 *   <li>  Template code is harder to read and understand. Custom templates create
     241 *         territories which only the code writer understands.
     242 *
     243 *   <li>  Errors in using templates create terrible C++ compiler messages.
     244 *
     245 *   <li>  Template code is really hard to look at in a debugger.
     246 *
     247 *   <li>  Templates slow down the compiler a lot.
     248 *
     249 * </ul>
     250 *
     251 * In particular, the following bits should be considered deprecated and should
     252 * NOT be used in new code:
     253 *
     254 * <ul>
     255 *
     256 *   <li>  everything in include/iprt/cpputils.h (auto_ref_ptr, exception_trap_base,
     257 *         char_auto_ptr and friends)
     258 *
     259 * </ul>
     260 *
     261 * Generally, in many cases, a simple class with a proper destructor can achieve
     262 * the same effect as a 1,000-line template include file, and the code is
     263 * much more accessible that way.
     264 *
     265 * Using standard STL templates like std::list, std::vector and std::map is OK.
     266 * Exceptions are:
     267 *
     268 * <ul>
     269 *
     270 *   <li>  Guest Additions because we don't want to link against libstdc++ there.
     271 *
     272 *   <li>  std::string should not be used because we have iprt::MiniString and
    251273 *     com::Utf8Str which can convert efficiently with COM's UTF-16 strings.
    252274 *
    253  *  -  std::auto_ptr<> in general; that part of the C++ standard is just broken.
     275 *   <li>  std::auto_ptr<> in general; that part of the C++ standard is just broken.
    254276 *     Write a destructor that calls delete.
    255277 *
     278 * </ul>
    256279 *
    257280 * @subsection sec_vbox_guideline_compulsory_cppqtgui   C++ guidelines for the Qt GUI
     
    262285 * the following rules should be respected:
    263286 *
    264  * - GUI classes which correspond to GUI tasks should be prefixed by UI (no VBox anymore)
    265  *
    266  * - Classes which extents some of the Qt classes should be prefix by QI
    267  *
    268  * - General task classes should be prefixed by C
    269  *
    270  * - Slots are prefixed by slt -> sltName
    271  *
    272  * - Signals are prefixed by sig -> sigName
    273  *
    274  * - Use Qt classes for lists, strings and so on, the use of STL classes should
     287 * <ul>
     288 *
     289 *   <li> GUI classes which correspond to GUI tasks should be prefixed by UI (no VBox anymore)
     290 *
     291 *   <li> Classes which extents some of the Qt classes should be prefix by QI
     292 *
     293 *   <li> General task classes should be prefixed by C
     294 *
     295 *   <li> Slots are prefixed by slt -> sltName
     296 *
     297 *   <li> Signals are prefixed by sig -> sigName
     298 *
     299 *   <li> Use Qt classes for lists, strings and so on, the use of STL classes should
    275300 *   be avoided
    276301 *
    277  * - All files like .cpp, .h, .ui, which belong together are located in the
     302 *   <li> All files like .cpp, .h, .ui, which belong together are located in the
    278303 *   same directory and named the same
     304 *
     305 * </ul>
    279306 *
    280307 *
     
    285312 * There are a couple of common pitfalls worth mentioning:
    286313 *
    287  *      - Never do repeated //interface[@name=...] and //enum[@name=...] lookups
     314 * <ul>
     315 *
     316 *   <li> Never do repeated //interface[\@name=...] and //enum[\@name=...] lookups
    288317 *        because they are expensive. Instead delcare xsl:key elements for these
    289318 *        searches and do the lookup using the key() function. xsltproc uses
    290319 *        (per current document) hash tables for each xsl:key, i.e. very fast.
    291320 *
    292  *      - When output type is 'text' make sure to call xsltprocNewlineOutputHack
     321 *   <li> When output type is 'text' make sure to call xsltprocNewlineOutputHack
    293322 *        from typemap-shared.inc.xsl every few KB of output, or xsltproc will
    294323 *        end up wasting all the time reallocating the output buffer.
    295324 *
     325 * </ul>
    296326 *
    297327 * @subsection sec_vbox_guideline_compulsory_doxygen    Doxygen Comments
     
    303333 * A couple of hints on how to best write doxygen comments:
    304334 *
    305  *      - A good class, method, function, structure or enum doxygen comment
     335 * <ul>
     336 *
     337 *   <li> A good class, method, function, structure or enum doxygen comment
    306338 *        starts with a one line sentence giving a brief description of the
    307339 *        item.  Details comes in a new paragraph (after blank line).
    308340 *
    309  *      - Except for list generators like \@todo, \@cfgm, \@gcfgm and others,
     341 *   <li> Except for list generators like \@todo, \@cfgm, \@gcfgm and others,
    310342 *        all doxygen comments are related to things in the code.  So, for
    311343 *        instance you DO NOT add a doxygen \@note comment in the middle of a
     
    313345 *        comment like 'Note! blah, very importan blah!'
    314346 *
    315  *      - We do NOT use TODO/XXX/BUGBUG or similar markers in the code to flag
     347 *   <li> We do NOT use TODO/XXX/BUGBUG or similar markers in the code to flag
    316348 *        things needing fixing later, we always use \@todo doxygen comments.
    317349 *
    318  *      - There is no colon after the \@todo.  And it is ALWAYS in a doxygen
     350 *   <li> There is no colon after the \@todo.  And it is ALWAYS in a doxygen
    319351 *        comment.
    320352 *
    321  *      - The \@retval tag is used to explain status codes a method/function may
     353 *   <li> The \@retval tag is used to explain status codes a method/function may
    322354 *        returns.  It is not used to describe output parameters, that is done
    323355 *        using the \@param or \@param[out] tag.
    324356 *
     357 * </ul>
     358 *
    325359 * See https://www.stack.nl/~dimitri/doxygen/manual/index.html for the official
    326360 * doxygen documention.
     
    335369 * @subsection sec_vbox_guideline_optional_layout   The code layout
    336370 *
    337  *      - Max line length is 130 chars.  Exceptions are table-like
     371 * <ul>
     372 *
     373 *   <li> Max line length is 130 chars.  Exceptions are table-like
    338374 *        code/initializers and Log*() statements (don't waste unnecessary
    339375 *        vertical space on debug logging).
    340376 *
    341  *      - Comments should try stay within the usual 80 columns as these are
     377 *   <li> Comments should try stay within the usual 80 columns as these are
    342378 *        denser and too long lines may be harder to read.
    343379 *
    344  *      - Curly brackets are not indented.  Example:
     380 *   <li> Curly brackets are not indented.  Example:
    345381 *        @code
    346382 *              if (true)
     
    356392 *        @endcode
    357393 *
    358  *      - Space before the parentheses when it comes after a C keyword.
    359  *
    360  *      - No space between argument and parentheses. Exception for complex
     394 *   <li> Space before the parentheses when it comes after a C keyword.
     395 *
     396 *   <li> No space between argument and parentheses. Exception for complex
    361397 *        expression.  Example:
    362398 *        @code
     
    364400 *        @endcode
    365401 *
    366  *      - The else of an if is always the first statement on a line. (No curly
     402 *   <li> The else of an if is always the first statement on a line. (No curly
    367403 *        stuff before it!)
    368404 *
    369  *      - else and if go on the same line if no { compound statement }
     405 *   <li> else and if go on the same line if no { compound statement }
    370406 *        follows the if.  Example:
    371407 *        @code
     
    380416 *        @endcode
    381417 *
    382  *
    383  *      - Slightly complex boolean expressions are split into multiple lines,
     418 *   <li> Slightly complex boolean expressions are split into multiple lines,
    384419 *        putting the operators first on the line and indenting it all according
    385420 *        to the nesting of the expression. The purpose is to make it as easy as
     
    390425 *        @endcode
    391426 *
    392  *      - When 'if' or  'while' statements gets long, the closing parentheses
     427 *   <li> When 'if' or  'while' statements gets long, the closing parentheses
    393428 *        goes right below the opening parentheses.  This may be applied to
    394429 *        sub-expression.  Example:
     
    406441 *        @endcode
    407442 *
    408  *      - The case is indented from the switch (to avoid having the braces for
     443 *   <li> The case is indented from the switch (to avoid having the braces for
    409444 *        the 'case' at the same level as the 'switch' statement).
    410445 *
    411  *      - If a case needs curly brackets they contain the entire case, are not
     446 *   <li> If a case needs curly brackets they contain the entire case, are not
    412447 *        indented from the case, and the break or return is placed inside them.
    413448 *        Example:
     
    427462 *        @endcode
    428463 *
    429  *      - In a do while construction, the while is on the same line as the
     464 *   <li> In a do while construction, the while is on the same line as the
    430465 *        closing "}" if any are used.
    431466 *        Example:
     
    438473 *        @endcode
    439474 *
    440  *      - Comments are in C style.  C++ style comments are used for temporary
     475 *   <li> Comments are in C style.  C++ style comments are used for temporary
    441476 *        disabling a few lines of code.
    442477 *
    443  *      - No unnecessary parentheses in expressions (just don't over do this
     478 *   <li> No unnecessary parentheses in expressions (just don't over do this
    444479 *        so that gcc / msc starts bitching). Find a correct C/C++ operator
    445480 *        precedence table if needed.
    446481 *
    447  *      - 'for (;;)' is preferred over 'while (true)' and 'while (1)'.
    448  *
    449  *      - Parameters are indented to the start parentheses when breaking up
     482 *   <li> 'for (;;)' is preferred over 'while (true)' and 'while (1)'.
     483 *
     484 *   <li> Parameters are indented to the start parentheses when breaking up
    450485 *        function calls, declarations or prototypes.  (This is in line with
    451486 *        how 'if', 'for' and 'while' statements are done as well.) Example:
     
    464499 *        @endcode
    465500 *
    466  *      - That Dijkstra is dead is no excuse for using gotos.
    467  *
    468  *      - Using do-while-false loops to avoid gotos is considered very bad form.
     501 *   <li> That Dijkstra is dead is no excuse for using gotos.
     502 *
     503 *   <li> Using do-while-false loops to avoid gotos is considered very bad form.
    469504 *        They create hard to read code.  They tend to be either too short (i.e.
    470505 *        pointless) or way to long (split up the function already), making
     
    475510 *        the code up into more functions!
    476511 *
     512 *   <li> Avoid code like
     513 *        @code
     514 *              int foo;
     515 *              int rc;
     516 *              ...
     517 *              rc = FooBar();
     518 *              if (RT_SUCCESS(rc))
     519 *              {
     520 *                  foo = getFoo();
     521 *                  ...
     522 *                  pvBar = RTMemAlloc(sizeof(*pvBar));
     523 *                  if (!pvBar)
     524 *                     rc = VERR_NO_MEMORY;
     525 *              }   
     526 *              if (RT_SUCCESS(rc))
     527 *              {
     528 *                  buzz = foo;
     529 *                  ...
     530 *              }
     531 *        @endcode
     532 *        The intention of such code is probably to save some horizontal space
     533 *        but unfortunately it's hard to read and the scope of certain varables
     534 *        (e.g. foo in this example) is not optimal. Better use the following
     535 *        style:
     536 *        @code
     537 *              int rc;
     538 *              ...
     539 *              rc = FooBar();
     540 *              if (RT_SUCCESS(rc))
     541 *              {
     542 *                  int foo = getFoo();
     543 *                  ...
     544 *                  pvBar = RTMemAlloc(sizeof(*pvBar));
     545 *                  if (pvBar)
     546 *                  {
     547 *                      buzz = foo;
     548 *                      ...
     549 *                  }
     550 *                  else
     551 *                      rc = VERR_NO_MEMORY;
     552 *              }
     553 *        @endcode
     554 *
     555 * </ul>
    477556 *
    478557 * @subsection sec_vbox_guideline_optional_prefix   Variable / Member Prefixes
     
    485564 * The prefixes:
    486565 *
    487  *      - The 'g_' (or 'g') prefix means a global variable, either on file or module level.
    488  *
    489  *      - The 's_' (or 's') prefix means a static variable inside a function or
     566 * <ul>
     567 *
     568 *   <li> The 'g_' (or 'g') prefix means a global variable, either on file or module level.
     569 *
     570 *   <li> The 's_' (or 's') prefix means a static variable inside a function or
    490571 *        class.  This is not used for static variables on file level, use 'g_'
    491572 *        for those (logical, right).
    492573 *
    493  *      - The 'm_' (or 'm') prefix means a class data member.
     574 *   <li> The 'm_' (or 'm') prefix means a class data member.
    494575 *
    495576 *        In new code in Main, use "m_" (and common sense).  As an exception,
     
    501582 *        already which is clear enough.
    502583 *
    503  *      - The 'a_' prefix means a parameter (argument) variable.  This is
     584 *   <li> The 'a_' prefix means a parameter (argument) variable.  This is
    504585 *        sometimes written 'a' in parts of the source code that does not use
    505586 *        the array prefix.
    506587 *
    507  *      - The 'p' prefix means pointer.  For instance 'pVM' is pointer to VM.
    508  *
    509  *      - The 'r' prefix means that something is passed by reference.
    510  *
    511  *      - The 'k' prefix means that something is a constant.  For instance
     588 *   <li> The 'p' prefix means pointer.  For instance 'pVM' is pointer to VM.
     589 *
     590 *   <li> The 'r' prefix means that something is passed by reference.
     591 *
     592 *   <li> The 'k' prefix means that something is a constant.  For instance
    512593 *        'enum { kStuff };'.  This is usually not used in combination with
    513594 *        'p', 'r' or any such thing, it's main main use is to make enums
    514595 *        easily identifiable.
    515596 *
    516  *      - The 'a' prefix means array.  For instance 'aPages' could be read as
     597 *   <li> The 'a' prefix means array.  For instance 'aPages' could be read as
    517598 *        array of pages.
    518599 *
    519  *      - The 'c' prefix means count.  For instance 'cbBlock' could be read,
     600 *   <li> The 'c' prefix means count.  For instance 'cbBlock' could be read,
    520601 *        count of bytes in block. (1)
    521602 *
    522  *      - The 'cx' prefix means width (count of 'x' units).
    523  *
    524  *      - The 'cy' prefix means height (count of 'y' units).
    525  *
    526  *      - The 'x', 'y' and 'z' prefix refers to the x-, y- , and z-axis
     603 *   <li> The 'cx' prefix means width (count of 'x' units).
     604 *
     605 *   <li> The 'cy' prefix means height (count of 'y' units).
     606 *
     607 *   <li> The 'x', 'y' and 'z' prefix refers to the x-, y- , and z-axis
    527608 *        respectively.
    528609 *
    529  *      - The 'off' prefix means offset.
    530  *
    531  *      - The 'i' or 'idx' prefixes usually means index.  Although the 'i' one
     610 *   <li> The 'off' prefix means offset.
     611 *
     612 *   <li> The 'i' or 'idx' prefixes usually means index.  Although the 'i' one
    532613 *        can sometimes just mean signed integer.
    533614 *
    534  *      - The 'i[1-9]+' prefix means a fixed bit size variable.  Frequently
     615 *   <li> The 'i[1-9]+' prefix means a fixed bit size variable.  Frequently
    535616 *        used with the int[1-9]+_t types where the width is really important.
    536617 *        In most cases 'i' is more appropriate.  [type]
    537618 *
    538  *      - The 'e' (or 'enm') prefix means enum.
    539  *
    540  *      - The 'u' prefix usually means unsigned integer.  Exceptions follows.
    541  *
    542  *      - The 'u[1-9]+' prefix means a fixed bit size variable.  Frequently
     619 *   <li> The 'e' (or 'enm') prefix means enum.
     620 *
     621 *   <li> The 'u' prefix usually means unsigned integer.  Exceptions follows.
     622 *
     623 *   <li> The 'u[1-9]+' prefix means a fixed bit size variable.  Frequently
    543624 *        used with the uint[1-9]+_t types and with bitfields where the width is
    544625 *        really important.  In most cases 'u' or 'b' (byte) would be more
    545626 *        appropriate.  [type]
    546627 *
    547  *      - The 'b' prefix means byte or bytes.  [type]
    548  *
    549  *      - The 'f' prefix means flags.  Flags are unsigned integers of some kind
     628 *   <li> The 'b' prefix means byte or bytes.  [type]
     629 *
     630 *   <li> The 'f' prefix means flags.  Flags are unsigned integers of some kind
    550631 *        or booleans.
    551632 *
    552  *      - TODO: need prefix for real float.  [type]
    553  *
    554  *      - The 'rd' prefix means real double and is used for 'double' variables.
     633 *   <li> TODO: need prefix for real float.  [type]
     634 *
     635 *   <li> The 'rd' prefix means real double and is used for 'double' variables.
    555636 *        [type]
    556637 *
    557  *      - The 'lrd' prefix means long real double and is used for 'long double'
     638 *   <li> The 'lrd' prefix means long real double and is used for 'long double'
    558639 *        variables. [type]
    559640 *
    560  *      - The 'ch' prefix means a char, the (signed) char type.  [type]
    561  *
    562  *      - The 'wc' prefix means a wide/windows char, the RTUTF16 type.  [type]
    563  *
    564  *      - The 'uc' prefix means a Unicode Code point, the RTUNICP type.  [type]
    565  *
    566  *      - The 'uch' prefix means unsigned char.  It's rarely used.  [type]
    567  *
    568  *      - The 'sz' prefix means zero terminated character string (array of
     641 *   <li> The 'ch' prefix means a char, the (signed) char type.  [type]
     642 *
     643 *   <li> The 'wc' prefix means a wide/windows char, the RTUTF16 type.  [type]
     644 *
     645 *   <li> The 'uc' prefix means a Unicode Code point, the RTUNICP type.  [type]
     646 *
     647 *   <li> The 'uch' prefix means unsigned char.  It's rarely used.  [type]
     648 *
     649 *   <li> The 'sz' prefix means zero terminated character string (array of
    569650 *        chars). (UTF-8)
    570651 *
    571  *      - The 'wsz' prefix means zero terminated wide/windows character string
     652 *   <li> The 'wsz' prefix means zero terminated wide/windows character string
    572653 *        (array of RTUTF16).
    573654 *
    574  *      - The 'usz' prefix means zero terminated Unicode string (array of
     655 *   <li> The 'usz' prefix means zero terminated Unicode string (array of
    575656 *        RTUNICP).
    576657 *
    577  *      - The 'str' prefix means C++ string; either a std::string or, in Main,
     658 *   <li> The 'str' prefix means C++ string; either a std::string or, in Main,
    578659 *        a Utf8Str or, in Qt, a QString.  When used with 'p', 'r', 'a' or 'c'
    579660 *        the first letter should be capitalized.
    580661 *
    581  *      - The 'bstr' prefix, in Main, means a UTF-16 Bstr. When used with 'p',
     662 *   <li> The 'bstr' prefix, in Main, means a UTF-16 Bstr. When used with 'p',
    582663 *        'r', 'a' or 'c' the first letter should be capitalized.
    583664 *
    584  *      - The 'pfn' prefix means pointer to function. Common usage is 'pfnCallback'
     665 *   <li> The 'pfn' prefix means pointer to function. Common usage is 'pfnCallback'
    585666 *        and such like.
    586667 *
    587  *      - The 'psz' prefix is a combination of 'p' and 'sz' and thus means
     668 *   <li> The 'psz' prefix is a combination of 'p' and 'sz' and thus means
    588669 *        pointer to a zero terminated character string. (UTF-8)
    589670 *
    590  *      - The 'pcsz' prefix is used to indicate constant string pointers in
     671 *   <li> The 'pcsz' prefix is used to indicate constant string pointers in
    591672 *        parts of the code.  Most code uses 'psz' for const and non-const
    592673 *        string pointers, so please ignore this one.
    593674 *
    594  *      - The 'l' prefix means (signed) long.  We try avoid using this,
     675 *   <li> The 'l' prefix means (signed) long.  We try avoid using this,
    595676 *        expecially with the 'LONG' types in Main as these are not 'long' on
    596677 *        64-bit non-Windows platforms and can cause confusion. Alternatives:
    597678 *        'i' or 'i32'.  [type]
    598679 *
    599  *      - The 'ul' prefix means unsigned long.  We try avoid using this,
     680 *   <li> The 'ul' prefix means unsigned long.  We try avoid using this,
    600681 *        expecially with the 'ULONG' types in Main as these are not 'unsigned
    601682 *        long' on 64-bit non-Windows platforms and can cause confusion.
    602683 *        Alternatives: 'u' or 'u32'.  [type]
    603684 *
     685 * </ul>
    604686 *
    605687 * (1)  Except in the occasional 'pcsz' prefix, the 'c' prefix is never ever
     
    609691 * @subsection sec_vbox_guideline_optional_misc     Misc / Advice / Stuff
    610692 *
    611  *      - When writing code think as the reader.
    612  *
    613  *      - When writing code think as the compiler. (2)
    614  *
    615  *      - When reading code think as if it's full of bugs - find them and fix them.
    616  *
    617  *      - Pointer within range tests like:
     693 * <ul>
     694 *
     695 *   <li> When writing code think as the reader.
     696 *
     697 *   <li> When writing code think as the compiler. (2)
     698 *
     699 *   <li> When reading code think as if it's full of bugs - find them and fix them.
     700 *
     701 *   <li> Pointer within range tests like:
    618702 *        @code
    619703 *          if ((uintptr_t)pv >= (uintptr_t)pvBase && (uintptr_t)pv < (uintptr_t)pvBase + cbRange)
     
    625709 *        Which is shorter and potentially faster. (1)
    626710 *
    627  *      - Avoid unnecessary casting. All pointers automatically cast down to
     711 *   <li> Avoid unnecessary casting. All pointers automatically cast down to
    628712 *        void *, at least for non class instance pointers.
    629713 *
    630  *      - It's very very bad practise to write a function larger than a
     714 *   <li> It's very very bad practise to write a function larger than a
    631715 *        screen full (1024x768) without any comprehensibility and explaining
    632716 *        comments.
    633717 *
    634  *      - More to come....
    635  *
     718 *   <li> More to come....
     719 *
     720 * </ul>
    636721 *
    637722 * (1)  Important, be very careful with the casting. In particular, note that
     
    684769 * Before checking in:
    685770 *
    686  *      - Check Tinderbox and make sure the tree is green across all platforms. If it's
     771 * <ul>
     772 *
     773 *   <li> Check Tinderbox and make sure the tree is green across all platforms. If it's
    687774 *        red on a platform, don't check in. If you want, warn in the \#vbox channel and
    688775 *        help make the responsible person fix it.
    689776 *        NEVER CHECK IN TO A BROKEN BUILD.
    690777 *
    691  *      - When checking in keep in mind that a commit is atomic and that the Tinderbox and
     778 *   <li> When checking in keep in mind that a commit is atomic and that the Tinderbox and
    692779 *        developers are constantly checking out the tree. Therefore do not split up the
    693780 *        commit unless it's into 100% independent parts. If you need to split it up in order
    694781 *        to have sensible commit comments, make the sub-commits as rapid as possible.
    695782 *
    696  *      - If you make a user visible change, such as fixing a reported bug,
     783 *   <li> If you make a user visible change, such as fixing a reported bug,
    697784 *        make sure you add an entry to doc/manual/user_ChangeLogImpl.xml.
    698785 *
    699  *      - If you are adding files make sure set the right attributes.
     786 *   <li> If you are adding files make sure set the right attributes.
    700787 *        svn-ps.sh/cmd was created for this purpose, please make use of it.
    701788 *
     789 * </ul>
    702790 *
    703791 * After checking in:
    704792 *
    705  *      - After checking-in, you watch Tinderbox until your check-ins clear. You do not
     793 * <ul>
     794 *
     795 *   <li> After checking-in, you watch Tinderbox until your check-ins clear. You do not
    706796 *        go home. You do not sleep. You do not log out or experiment with drugs. You do
    707797 *        not become unavailable. If you break the tree, add a comment saying that you're
     
    709799 *        out the change.
    710800 *
     801 * </ul>
     802 *
    711803 * (Inspired by mozilla tree rules.)
    712804 */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette