diff options
| author | 2015-07-11 19:59:50 -0300 | |
|---|---|---|
| committer | 2015-07-11 19:59:50 -0300 | |
| commit | d4f19736a6fa05109a87702e512f7652d1340e80 (patch) | |
| tree | 672c2c4c251351cc07581b09ad1efae67479c297 /CONTRIBUTING.md | |
| parent | Merge pull request #909 from yuriks/build-flags (diff) | |
| download | yuzu-d4f19736a6fa05109a87702e512f7652d1340e80.tar.gz yuzu-d4f19736a6fa05109a87702e512f7652d1340e80.tar.xz yuzu-d4f19736a6fa05109a87702e512f7652d1340e80.zip | |
Update style rules with to better match current practice.
Diffstat (limited to '')
| -rw-r--r-- | CONTRIBUTING.md | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 906a4bc7d..f2dbdf1a4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md | |||
| @@ -7,19 +7,14 @@ Citra is a brand new project, so we have a great opportunity to keep things clea | |||
| 7 | * Don't ever introduce new external dependencies into Core | 7 | * Don't ever introduce new external dependencies into Core |
| 8 | * Don't use any platform specific code in Core | 8 | * Don't use any platform specific code in Core |
| 9 | * Use namespaces often | 9 | * Use namespaces often |
| 10 | * Avoid the use of C-style casts and instead prefer C++-style `static_cast` and `reinterpret_cast`. Never use `const_cast` or `dynamic_cast` (we build with RTTI disabled). The only exception to this rule is for casting between two numeric types, where C-style casts are encouraged for brevity and readability. | ||
| 10 | 11 | ||
| 11 | ### Naming Rules | 12 | ### Naming Rules |
| 12 | * Functions | 13 | * Functions: `PascalCase` |
| 13 | * PascalCase, "_" may also be used for clarity (e.g. ARM_InitCore) | 14 | * Variables: `lower_case_underscored`. Prefix with `g_` if global. |
| 14 | * Variables | 15 | * Classes: `PascalCase` |
| 15 | * lower_case_underscored | 16 | * Files and Directories: `lower_case_underscored` |
| 16 | * Prefix "g_" if global | 17 | * Namespaces: `PascalCase`, `_` may also be used for clarity (e.g. `ARM_InitCore`) |
| 17 | * Classes | ||
| 18 | * PascalCase, "_" may also be used for clarity (e.g. OGL_VideoInterface) | ||
| 19 | * Files/Folders | ||
| 20 | * lower_case_underscored | ||
| 21 | * Namespaces | ||
| 22 | * PascalCase, "_" may also be used for clarity (e.g. ARM_InitCore) | ||
| 23 | 18 | ||
| 24 | ### Indentation/Whitespace Style | 19 | ### Indentation/Whitespace Style |
| 25 | Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spaces instead. | 20 | Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spaces instead. |
| @@ -36,25 +31,25 @@ namespace Example { | |||
| 36 | 31 | ||
| 37 | // Declare globals at the top | 32 | // Declare globals at the top |
| 38 | int g_foo = 0; | 33 | int g_foo = 0; |
| 39 | char* g_some_pointer; // Notice the position of the * | 34 | char* g_some_pointer; // Pointer * and reference & stick to the type name |
| 40 | 35 | ||
| 41 | /// A colorful enum. | 36 | /// A colorful enum. |
| 42 | enum SomeEnum { | 37 | enum SomeEnum { |
| 43 | COLOR_RED, ///< The color of fire. | 38 | COLOR_RED, ///< The color of fire. |
| 44 | COLOR_GREEN, ///< The color of grass. | 39 | COLOR_GREEN, ///< The color of grass. |
| 45 | COLOR_BLUE ///< Not actually the color of water. | 40 | COLOR_BLUE, ///< Not actually the color of water. |
| 46 | }; | 41 | }; |
| 47 | 42 | ||
| 48 | /** | 43 | /** |
| 49 | * Very important struct that does a lot of stuff. | 44 | * Very important struct that does a lot of stuff. |
| 50 | * Note that the asterisks are indented by one space. | 45 | * Note that the asterisks are indented by one space to align to the first line. |
| 51 | */ | 46 | */ |
| 52 | struct Position { | 47 | struct Position { |
| 53 | int x, y; | 48 | int x, y; |
| 54 | }; | 49 | }; |
| 55 | 50 | ||
| 56 | // Use "typename" rather than "class" here, just to be consistent | 51 | // Use "typename" rather than "class" here |
| 57 | template | 52 | template <typename T> |
| 58 | void FooBar() { | 53 | void FooBar() { |
| 59 | int some_array[] = { | 54 | int some_array[] = { |
| 60 | 5, | 55 | 5, |
| @@ -72,7 +67,7 @@ void FooBar() { | |||
| 72 | // Comment directly above code when possible | 67 | // Comment directly above code when possible |
| 73 | if (some_condition) single_statement(); | 68 | if (some_condition) single_statement(); |
| 74 | 69 | ||
| 75 | // Place a single space after the for loop semicolons | 70 | // Place a single space after the for loop semicolons, prefer pre-increment |
| 76 | for (int i = 0; i != 25; ++i) { | 71 | for (int i = 0; i != 25; ++i) { |
| 77 | // This is how we write loops | 72 | // This is how we write loops |
| 78 | } | 73 | } |
| @@ -83,6 +78,9 @@ void FooBar() { | |||
| 83 | if (this || condition_takes_up_multiple && | 78 | if (this || condition_takes_up_multiple && |
| 84 | lines && like && this || everything || | 79 | lines && like && this || everything || |
| 85 | alright || then) { | 80 | alright || then) { |
| 81 | |||
| 82 | // Leave a blank space before the if block body if the condition was continued across | ||
| 83 | // several lines. | ||
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | switch (var) { | 86 | switch (var) { |
| @@ -101,11 +99,7 @@ void FooBar() { | |||
| 101 | break; | 99 | break; |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | std::vector | 102 | std::vector<T> you_can_declare, a_few, variables, like_this; |
| 105 | you_can_declare, | ||
| 106 | a_few, | ||
| 107 | variables, | ||
| 108 | like_this; | ||
| 109 | } | 103 | } |
| 110 | 104 | ||
| 111 | } | 105 | } |