Changeset 68445 in vbox
- Timestamp:
- Aug 17, 2017 1:27:05 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/doc/VBox-CodingGuidelines.cpp (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/VBox-CodingGuidelines.cpp
r63292 r68445 29 29 * @section sec_vbox_guideline_compulsory Compulsory 30 30 * 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 45 46 * and avoids nasty name clash problems which can occur, especially on 46 47 * Unix-like systems. (1) It also simplifies locating callers when 47 48 * changing it (single source file vs entire VBox tree). 48 49 * 49 * -Public names are of the form Domain[Subdomain[]]Method, using mixed50 * <li> Public names are of the form Domain[Subdomain[]]Method, using mixed 50 51 * casing to mark the words. The main domain is all uppercase. 51 52 * (Think like java, mapping domain and subdomain to packages/classes.) 52 53 * 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. 58 59 * This applies to enum values too. 59 60 * 60 * -Typedefs are all uppercase and contain no underscores to distinguish61 * <li> Typedefs are all uppercase and contain no underscores to distinguish 61 62 * them from defines. 62 63 * 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 as64 * <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 74 75 * they do not have to be valid UTF-8. Only trust internal strings. 75 76 * 76 * -All functions return VBox status codes. There are three general77 * <li> All functions return VBox status codes. There are three general 77 78 * 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 79 82 * nature and usage. They return bool. The function name will 80 83 * include 'Has', 'Is' or similar. 81 * -#Functions which by nature cannot possibly fail.84 * <li>Functions which by nature cannot possibly fail. 82 85 * These return void. 83 * -#"Get"-functions which return what they ask for.86 * <li>"Get"-functions which return what they ask for. 84 87 * A get function becomes a "Query" function if there is any 85 88 * 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 97 103 * the platforms. 98 104 * 99 * -The use of symbols leading with single or double underscores is105 * <li> The use of symbols leading with single or double underscores is 100 106 * forbidden as that intrudes on reserved compiler/system namespace. (3) 101 107 * 102 * -All files have file headers with $Id and a file tag which describes108 * <li> All files have file headers with $Id and a file tag which describes 103 109 * the file in a sentence or two. 104 110 * Note: Use the svn-ps.cmd/svn-ps.sh utility with the -a option to add … … 106 112 * configured. 107 113 * 108 * -All public functions are fully documented in Doxygen style using the114 * <li> All public functions are fully documented in Doxygen style using the 109 115 * javadoc dialect (using the 'at' instead of the 'slash' as 110 116 * commandprefix.) 111 117 * 112 * -All structures in header files are described, including all their118 * <li> All structures in header files are described, including all their 113 119 * members. (Doxygen style, of course.) 114 120 * 115 * -All modules have a documentation '\@page' in the main source file121 * <li> All modules have a documentation '\@page' in the main source file 116 122 * which describes the intent and actual implementation. 117 123 * 118 * -Code which is doing things that are not immediately comprehensible124 * <li> Code which is doing things that are not immediately comprehensible 119 125 * shall include explanatory comments. 120 126 * 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++ 124 130 * comments, only ANSI C comments! 125 131 * 126 * -Comments on \#else indicates what begins while the comment on a132 * <li> Comments on \#else indicates what begins while the comment on a 127 133 * \#endif indicates what ended. Only add these when there are more than 128 134 * a few lines (6-10) of \#ifdef'ed code, otherwise they're just clutter. 129 * 135 * </ul> 130 136 * 131 137 * (1) It is common practice on Unix to have a single symbol namespace for an … … 150 156 * Some facts first: 151 157 * 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 153 161 * 64-bit platforms long is 64-bit. 154 162 * 155 * -On all 64-bit platforms we care about, int is 32-bit, short is 16 bit163 * <li> On all 64-bit platforms we care about, int is 32-bit, short is 16 bit 156 164 * and char is 8-bit. 157 165 * (I don't know about any platforms yet where this isn't true.) 158 166 * 159 * -size_t, ssize_t, uintptr_t, ptrdiff_t and similar are all 64-bit on167 * <li> size_t, ssize_t, uintptr_t, ptrdiff_t and similar are all 64-bit on 160 168 * 64-bit platforms. (These are 32-bit on 32-bit platforms.) 161 169 * 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> 164 173 * 165 174 * Now for the guidelines: 166 175 * 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 168 179 * pointer to integer. Use uintptr_t or intptr_t. If you have to use 169 180 * NT/Windows types, there is the choice of ULONG_PTR and DWORD_PTR. 170 181 * 171 * -Avoid where ever possible the use of the types 'long' and 'unsigned182 * <li> Avoid where ever possible the use of the types 'long' and 'unsigned 172 183 * long' as these differs in size between windows and the other hosts 173 184 * (see above). 174 185 * 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__, 176 187 * __WIN64__ and __WIN__ because they are all deprecated and scheduled 177 188 * for removal (if not removed already). Do not use the compiler … … 194 205 * @endcode 195 206 * 196 * -There are RT_OS_xxx defines for each OS, just like RT_OS_WINDOWS207 * <li> There are RT_OS_xxx defines for each OS, just like RT_OS_WINDOWS 197 208 * mentioned above. Use these defines instead of any predefined 198 209 * compiler stuff or defines from system headers. 199 210 * 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. 201 212 * Do not use __x86__, __X86__, __[Ii]386__, __[Ii]586__, or similar 202 213 * for this purpose. 203 214 * 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. 205 216 * Do not use __AMD64__, __amd64__ or __x64_86__. 206 217 * 207 * -Take care and use size_t when you have to, esp. when passing a pointer218 * <li> Take care and use size_t when you have to, esp. when passing a pointer 208 219 * to a size_t as a parameter. 209 220 * 210 * -Be wary of type promotion to (signed) integer. For example the221 * <li> Be wary of type promotion to (signed) integer. For example the 211 222 * following will cause u8 to be promoted to int in the shift, and then 212 223 * sign extended in the assignment 64-bit: … … 217 228 * @endcode 218 229 * 230 * </ul> 219 231 * 220 232 * @subsection sec_vbox_guideline_compulsory_cppmain C++ guidelines for Main … … 224 236 * instead of more for the following reasons: 225 237 * 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 251 273 * com::Utf8Str which can convert efficiently with COM's UTF-16 strings. 252 274 * 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. 254 276 * Write a destructor that calls delete. 255 277 * 278 * </ul> 256 279 * 257 280 * @subsection sec_vbox_guideline_compulsory_cppqtgui C++ guidelines for the Qt GUI … … 262 285 * the following rules should be respected: 263 286 * 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 275 300 * be avoided 276 301 * 277 * -All files like .cpp, .h, .ui, which belong together are located in the302 * <li> All files like .cpp, .h, .ui, which belong together are located in the 278 303 * same directory and named the same 304 * 305 * </ul> 279 306 * 280 307 * … … 285 312 * There are a couple of common pitfalls worth mentioning: 286 313 * 287 * - Never do repeated //interface[@name=...] and //enum[@name=...] lookups 314 * <ul> 315 * 316 * <li> Never do repeated //interface[\@name=...] and //enum[\@name=...] lookups 288 317 * because they are expensive. Instead delcare xsl:key elements for these 289 318 * searches and do the lookup using the key() function. xsltproc uses 290 319 * (per current document) hash tables for each xsl:key, i.e. very fast. 291 320 * 292 * -When output type is 'text' make sure to call xsltprocNewlineOutputHack321 * <li> When output type is 'text' make sure to call xsltprocNewlineOutputHack 293 322 * from typemap-shared.inc.xsl every few KB of output, or xsltproc will 294 323 * end up wasting all the time reallocating the output buffer. 295 324 * 325 * </ul> 296 326 * 297 327 * @subsection sec_vbox_guideline_compulsory_doxygen Doxygen Comments … … 303 333 * A couple of hints on how to best write doxygen comments: 304 334 * 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 306 338 * starts with a one line sentence giving a brief description of the 307 339 * item. Details comes in a new paragraph (after blank line). 308 340 * 309 * -Except for list generators like \@todo, \@cfgm, \@gcfgm and others,341 * <li> Except for list generators like \@todo, \@cfgm, \@gcfgm and others, 310 342 * all doxygen comments are related to things in the code. So, for 311 343 * instance you DO NOT add a doxygen \@note comment in the middle of a … … 313 345 * comment like 'Note! blah, very importan blah!' 314 346 * 315 * -We do NOT use TODO/XXX/BUGBUG or similar markers in the code to flag347 * <li> We do NOT use TODO/XXX/BUGBUG or similar markers in the code to flag 316 348 * things needing fixing later, we always use \@todo doxygen comments. 317 349 * 318 * -There is no colon after the \@todo. And it is ALWAYS in a doxygen350 * <li> There is no colon after the \@todo. And it is ALWAYS in a doxygen 319 351 * comment. 320 352 * 321 * -The \@retval tag is used to explain status codes a method/function may353 * <li> The \@retval tag is used to explain status codes a method/function may 322 354 * returns. It is not used to describe output parameters, that is done 323 355 * using the \@param or \@param[out] tag. 324 356 * 357 * </ul> 358 * 325 359 * See https://www.stack.nl/~dimitri/doxygen/manual/index.html for the official 326 360 * doxygen documention. … … 335 369 * @subsection sec_vbox_guideline_optional_layout The code layout 336 370 * 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 338 374 * code/initializers and Log*() statements (don't waste unnecessary 339 375 * vertical space on debug logging). 340 376 * 341 * -Comments should try stay within the usual 80 columns as these are377 * <li> Comments should try stay within the usual 80 columns as these are 342 378 * denser and too long lines may be harder to read. 343 379 * 344 * -Curly brackets are not indented. Example:380 * <li> Curly brackets are not indented. Example: 345 381 * @code 346 382 * if (true) … … 356 392 * @endcode 357 393 * 358 * -Space before the parentheses when it comes after a C keyword.359 * 360 * -No space between argument and parentheses. Exception for complex394 * <li> Space before the parentheses when it comes after a C keyword. 395 * 396 * <li> No space between argument and parentheses. Exception for complex 361 397 * expression. Example: 362 398 * @code … … 364 400 * @endcode 365 401 * 366 * -The else of an if is always the first statement on a line. (No curly402 * <li> The else of an if is always the first statement on a line. (No curly 367 403 * stuff before it!) 368 404 * 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 } 370 406 * follows the if. Example: 371 407 * @code … … 380 416 * @endcode 381 417 * 382 * 383 * - Slightly complex boolean expressions are split into multiple lines, 418 * <li> Slightly complex boolean expressions are split into multiple lines, 384 419 * putting the operators first on the line and indenting it all according 385 420 * to the nesting of the expression. The purpose is to make it as easy as … … 390 425 * @endcode 391 426 * 392 * -When 'if' or 'while' statements gets long, the closing parentheses427 * <li> When 'if' or 'while' statements gets long, the closing parentheses 393 428 * goes right below the opening parentheses. This may be applied to 394 429 * sub-expression. Example: … … 406 441 * @endcode 407 442 * 408 * -The case is indented from the switch (to avoid having the braces for443 * <li> The case is indented from the switch (to avoid having the braces for 409 444 * the 'case' at the same level as the 'switch' statement). 410 445 * 411 * -If a case needs curly brackets they contain the entire case, are not446 * <li> If a case needs curly brackets they contain the entire case, are not 412 447 * indented from the case, and the break or return is placed inside them. 413 448 * Example: … … 427 462 * @endcode 428 463 * 429 * -In a do while construction, the while is on the same line as the464 * <li> In a do while construction, the while is on the same line as the 430 465 * closing "}" if any are used. 431 466 * Example: … … 438 473 * @endcode 439 474 * 440 * -Comments are in C style. C++ style comments are used for temporary475 * <li> Comments are in C style. C++ style comments are used for temporary 441 476 * disabling a few lines of code. 442 477 * 443 * -No unnecessary parentheses in expressions (just don't over do this478 * <li> No unnecessary parentheses in expressions (just don't over do this 444 479 * so that gcc / msc starts bitching). Find a correct C/C++ operator 445 480 * precedence table if needed. 446 481 * 447 * -'for (;;)' is preferred over 'while (true)' and 'while (1)'.448 * 449 * -Parameters are indented to the start parentheses when breaking up482 * <li> 'for (;;)' is preferred over 'while (true)' and 'while (1)'. 483 * 484 * <li> Parameters are indented to the start parentheses when breaking up 450 485 * function calls, declarations or prototypes. (This is in line with 451 486 * how 'if', 'for' and 'while' statements are done as well.) Example: … … 464 499 * @endcode 465 500 * 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. 469 504 * They create hard to read code. They tend to be either too short (i.e. 470 505 * pointless) or way to long (split up the function already), making … … 475 510 * the code up into more functions! 476 511 * 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> 477 556 * 478 557 * @subsection sec_vbox_guideline_optional_prefix Variable / Member Prefixes … … 485 564 * The prefixes: 486 565 * 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 490 571 * class. This is not used for static variables on file level, use 'g_' 491 572 * for those (logical, right). 492 573 * 493 * -The 'm_' (or 'm') prefix means a class data member.574 * <li> The 'm_' (or 'm') prefix means a class data member. 494 575 * 495 576 * In new code in Main, use "m_" (and common sense). As an exception, … … 501 582 * already which is clear enough. 502 583 * 503 * -The 'a_' prefix means a parameter (argument) variable. This is584 * <li> The 'a_' prefix means a parameter (argument) variable. This is 504 585 * sometimes written 'a' in parts of the source code that does not use 505 586 * the array prefix. 506 587 * 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 instance588 * <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 512 593 * 'enum { kStuff };'. This is usually not used in combination with 513 594 * 'p', 'r' or any such thing, it's main main use is to make enums 514 595 * easily identifiable. 515 596 * 516 * -The 'a' prefix means array. For instance 'aPages' could be read as597 * <li> The 'a' prefix means array. For instance 'aPages' could be read as 517 598 * array of pages. 518 599 * 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, 520 601 * count of bytes in block. (1) 521 602 * 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-axis603 * <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 527 608 * respectively. 528 609 * 529 * -The 'off' prefix means offset.530 * 531 * -The 'i' or 'idx' prefixes usually means index. Although the 'i' one610 * <li> The 'off' prefix means offset. 611 * 612 * <li> The 'i' or 'idx' prefixes usually means index. Although the 'i' one 532 613 * can sometimes just mean signed integer. 533 614 * 534 * -The 'i[1-9]+' prefix means a fixed bit size variable. Frequently615 * <li> The 'i[1-9]+' prefix means a fixed bit size variable. Frequently 535 616 * used with the int[1-9]+_t types where the width is really important. 536 617 * In most cases 'i' is more appropriate. [type] 537 618 * 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. Frequently619 * <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 543 624 * used with the uint[1-9]+_t types and with bitfields where the width is 544 625 * really important. In most cases 'u' or 'b' (byte) would be more 545 626 * appropriate. [type] 546 627 * 547 * -The 'b' prefix means byte or bytes. [type]548 * 549 * -The 'f' prefix means flags. Flags are unsigned integers of some kind628 * <li> The 'b' prefix means byte or bytes. [type] 629 * 630 * <li> The 'f' prefix means flags. Flags are unsigned integers of some kind 550 631 * or booleans. 551 632 * 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. 555 636 * [type] 556 637 * 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' 558 639 * variables. [type] 559 640 * 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 of641 * <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 569 650 * chars). (UTF-8) 570 651 * 571 * -The 'wsz' prefix means zero terminated wide/windows character string652 * <li> The 'wsz' prefix means zero terminated wide/windows character string 572 653 * (array of RTUTF16). 573 654 * 574 * -The 'usz' prefix means zero terminated Unicode string (array of655 * <li> The 'usz' prefix means zero terminated Unicode string (array of 575 656 * RTUNICP). 576 657 * 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, 578 659 * a Utf8Str or, in Qt, a QString. When used with 'p', 'r', 'a' or 'c' 579 660 * the first letter should be capitalized. 580 661 * 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', 582 663 * 'r', 'a' or 'c' the first letter should be capitalized. 583 664 * 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' 585 666 * and such like. 586 667 * 587 * -The 'psz' prefix is a combination of 'p' and 'sz' and thus means668 * <li> The 'psz' prefix is a combination of 'p' and 'sz' and thus means 588 669 * pointer to a zero terminated character string. (UTF-8) 589 670 * 590 * -The 'pcsz' prefix is used to indicate constant string pointers in671 * <li> The 'pcsz' prefix is used to indicate constant string pointers in 591 672 * parts of the code. Most code uses 'psz' for const and non-const 592 673 * string pointers, so please ignore this one. 593 674 * 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, 595 676 * expecially with the 'LONG' types in Main as these are not 'long' on 596 677 * 64-bit non-Windows platforms and can cause confusion. Alternatives: 597 678 * 'i' or 'i32'. [type] 598 679 * 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, 600 681 * expecially with the 'ULONG' types in Main as these are not 'unsigned 601 682 * long' on 64-bit non-Windows platforms and can cause confusion. 602 683 * Alternatives: 'u' or 'u32'. [type] 603 684 * 685 * </ul> 604 686 * 605 687 * (1) Except in the occasional 'pcsz' prefix, the 'c' prefix is never ever … … 609 691 * @subsection sec_vbox_guideline_optional_misc Misc / Advice / Stuff 610 692 * 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: 618 702 * @code 619 703 * if ((uintptr_t)pv >= (uintptr_t)pvBase && (uintptr_t)pv < (uintptr_t)pvBase + cbRange) … … 625 709 * Which is shorter and potentially faster. (1) 626 710 * 627 * -Avoid unnecessary casting. All pointers automatically cast down to711 * <li> Avoid unnecessary casting. All pointers automatically cast down to 628 712 * void *, at least for non class instance pointers. 629 713 * 630 * -It's very very bad practise to write a function larger than a714 * <li> It's very very bad practise to write a function larger than a 631 715 * screen full (1024x768) without any comprehensibility and explaining 632 716 * comments. 633 717 * 634 * - More to come.... 635 * 718 * <li> More to come.... 719 * 720 * </ul> 636 721 * 637 722 * (1) Important, be very careful with the casting. In particular, note that … … 684 769 * Before checking in: 685 770 * 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 687 774 * red on a platform, don't check in. If you want, warn in the \#vbox channel and 688 775 * help make the responsible person fix it. 689 776 * NEVER CHECK IN TO A BROKEN BUILD. 690 777 * 691 * -When checking in keep in mind that a commit is atomic and that the Tinderbox and778 * <li> When checking in keep in mind that a commit is atomic and that the Tinderbox and 692 779 * developers are constantly checking out the tree. Therefore do not split up the 693 780 * commit unless it's into 100% independent parts. If you need to split it up in order 694 781 * to have sensible commit comments, make the sub-commits as rapid as possible. 695 782 * 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, 697 784 * make sure you add an entry to doc/manual/user_ChangeLogImpl.xml. 698 785 * 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. 700 787 * svn-ps.sh/cmd was created for this purpose, please make use of it. 701 788 * 789 * </ul> 702 790 * 703 791 * After checking in: 704 792 * 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 706 796 * go home. You do not sleep. You do not log out or experiment with drugs. You do 707 797 * not become unavailable. If you break the tree, add a comment saying that you're … … 709 799 * out the change. 710 800 * 801 * </ul> 802 * 711 803 * (Inspired by mozilla tree rules.) 712 804 */
Note:
See TracChangeset
for help on using the changeset viewer.

