Changeset 12863 in webkit
- Timestamp:
- Feb 16, 2006 4:32:02 PM (18 years ago)
- Location:
- trunk/WebKitSite
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitSite/ChangeLog
r12846 r12863 1 2006-02-16 Justin Garcia <justin.garcia@apple.com> 2 3 Changed by Darin on my machine. 4 5 * coding/coding-style.html: Re-merged in changes Darin made to the guidelines 6 a few days back. 7 1 8 2006-02-16 Joost de Valk <jdevalk@opendarwin.org> 2 9 -
trunk/WebKitSite/coding/coding-style.html
r12839 r12863 9 9 10 10 <ol> 11 <li> Use spaces to indent. Tabs should not appear in code files (with the exception of files that require them e.g. Makefiles).</li> 11 <li> Use spaces to indent. Tabs should not appear in code files (with the exception of files that require tabs, e.g. Makefiles). 12 We have a Subversion pre-commit script that enforces this rule for most 13 source files, preventing commits of files that don't follow this rule. 14 </li> 12 15 <li> The indent size is 4 spaces.</li> 13 16 <li> Code editors should be configured to expand tabs that you type to 4 spaces.</li> … … 16 19 <h3>Braces</h3> 17 20 <ol> 18 <li> Function definitions -open and close braces should be on lines by themselves. Do not put the open brace on the same line as the function signature. For example:<br />21 <li> Function definitions — open and close braces should be on lines by themselves. Do not put the open brace on the same line as the function signature. For example:<br /> 19 22 20 23 <h4 style="color: #008000 !important !important">Right:</h4> … … 33 36 </pre> 34 37 </li> 35 <li> Loop control structures, including for, while and do statements -the open brace should go on the same line as the as the control structure.<br />38 <li> Loop control structures, including for, while and do statements — the open brace should go on the same line as the as the control structure.<br /> 36 39 37 40 <h4 style="color: #008000 !important">Right:</h4> … … 50 53 } 51 54 </pre> 52 <li> If/else statements - as above, but if there is an else clause, the close brace should go on the same line as the else. Also, one-line if or else clauses should not get braces.<br />53 55 <li> If/else statements — as above, but if there is an else clause, the close brace should go on the same line as the else. 56 Also, one-line if or else clauses should not get braces.<br /> 54 57 <h4 style="color: #008000 !important">Right:</h4> 55 58 <pre style="background-color: #F2F2F2"> … … 90 93 <h3>Parentheses</h3> 91 94 <ol> 92 <li>Function declarations and calls - do not use any spaces between the name and the open paren, inside the parentheses, or before commas that separate arguments. Do use a single space after commas that separate arguments.<br /> 95 <li>Function declarations and calls — do not use any spaces between the name and the open paren, inside the parentheses, or before commas that separate arguments. 96 Do use a single space after commas that separate arguments.<br /> 93 97 94 98 <h4 style="color: #008000 !important">Right:</h4> 95 99 <pre style="background-color: #F2F2F2"> 96 100 int myFunction(int arg1, float arg2); 97 101 98 102 void noArgFunction(); // for C++ or Objective-C++ 99 103 100 104 void noArgFunction(void); // for C or Objective-C 101 105 </pre> … … 104 108 <pre style="background-color: #F2F2F2"> 105 109 int myFunction (int arg1, float arg2); 106 110 107 111 int myFunction( int arg1 , float arg2 ); 108 112 109 113 void noArgFunction (); 110 114 </pre> 111 115 </li> 112 116 113 <li>Control structures, such as if, while, do and switch -use a single space before the open paren, but no spaces inside the parentheses.117 <li>Control structures, such as if, while, do and switch — use a single space before the open paren, but no spaces inside the parentheses. 114 118 115 119 </li> … … 184 188 <ol> 185 189 <li>General Rule: With very few exceptions, prefer embedded capitals instead of underscores for class, function and variable names.</p></li> 186 <li>C++ and Objective-C classes, interfaces and protocols, and other type names -these names should start with a capital letter and use InterCaps.<br />190 <li>C++ and Objective-C classes, interfaces and protocols, and other type names &emdash; these names should start with a capital letter and use InterCaps.<br /> 187 191 188 192 <h4 style="color: #008000 !important">Right:</h4> … … 218 222 <li>C++ data members should be named like local variables, but with a prefix of m_.</li> 219 223 <li>C++ member functions should follow the same naming convention as free functions.</li> 220 <li>Objective-C methods should follow the usual Cocoa naming style - they should read like a phrase or sentence and each piece of the selector should start with a lowercase letter and use intercaps.</li> 224 <li>Objective-C methods should follow the usual Cocoa naming style — 225 they should read like a phrase or sentence and each piece of the selector should start with a lowercase letter and use intercaps.</li> 221 226 <li>Objective-C instance variables should be named like local variables but starting with an underscore.</li> 222 <li>Pointer and reference types - pointer types should be written with a space between the type name and the * (so the * is adjacent to the following identifier if any). For reference types, the & goes next to the type name.</li>223 227 <li>Enum members should user InterCaps with an initial capital letter.</li> 224 228 <li>#defined constants should use all uppercase names with words separated by underscores.</li> … … 241 245 </li> 242 246 243 <li> Acronyms in names: If an identifier includes an acronym, make the acronym all-uppercase or all-lowercase, depending on whether a word in that position would be capitalized or not.<br /> 247 <li> Acronyms in names: If an identifier includes an acronym, make the acronym all-uppercase 248 or all-lowercase, depending on whether a word in that position would be capitalized or not.<br /> 244 249 245 250 <h4 style="color: #008000 !important">Right:</h4> … … 256 261 </li> 257 262 </ol> 263 264 <h3>Other Punctuation</h3> 265 266 <ol> 267 268 <li>Pointer and reference types in C++ code — Both pointer types and reference types 269 should be written with no space between the type name and the * or &. 270 271 <li>Pointer types in non-C++ code — Pointer types should be written with a space between the 272 type and the * (so the * is adjacent to the following identifier if any). 273 274 </ol> 275 276 <h3>Include Statements</h3> 277 278 <ol> 279 280 <li>All files must #include "config.h" first. 281 282 <li>All files must #include the primary header second, just after "config.h". 283 So for example, Node.cpp should include Node.h first, before other files. 284 This guarantees that each header's completeness is tested, to make sure it 285 can be compiled without requiring any other header files be included first. 286 287 <li>Other #include statements should be in sorted order (case sensitive, as 288 done by the command-line sort tool or the Xcode sort selection command). 289 Don't bother to organize them in a logical order. 290 291 </ol> 292 258 293 <?php 259 294 include("../footer.inc");
Note: See TracChangeset
for help on using the changeset viewer.