summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md107
-rw-r--r--README.md2
2 files changed, 108 insertions, 1 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..74c84b002
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,107 @@
1# Contributing
2
3Citra is a brand new project, so we have a great opportunity to keep things clean and well organized early on. As such, coding style is very important when making commits. They aren't very strict rules since we want to be flexible and we understand that under certain circumstances some of them can be counterproductive. Just try to follow as many of them as possible:
4
5### General Rules
6* A lot of code was taken from other projects (e.g. Dolphin, PPSSPP, Gekko, SkyEye). In general, when editing other people's code, follow the style of the module you're in (or better yet, fix the style if it drastically differs from our guide).
7* Line width is typically 100 characters, but this isn't strictly enforced. Please do not use 80-characters.
8* Don't ever introduce new external dependencies into Core
9* Don't use any platform specific code in Core
10* Use namespaces often
11
12### Naming Rules
13* Functions
14 * CamelCase, "_" may also be used for clarity (e.g. ARM_InitCore)
15* Variables
16 * lower_case_underscored
17 * Prefix "g_" if global
18 * Prefix "_" if internal
19 * Prefix "__" if ultra internal
20* Classes
21 * CamelCase, "_" may also be used for clarity (e.g. OGL_VideoInterface)
22* Files/Folders
23 * lower_case_underscored
24* Namespaces
25 * CamelCase, "_" may also be used for clarity (e.g. ARM_InitCore)
26
27### Indentation/Whitespace Style
28Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spaces instead.
29
30```cpp
31namespace Example {
32
33// Namespace contents are not indented
34
35// Declare globals at the top
36int g_foo = 0;
37char* g_some_pointer; // Notice the position of the *
38
39enum SomeEnum {
40 COLOR_RED,
41 COLOR_GREEN,
42 COLOR_BLUE
43};
44
45struct Position {
46 int x, y;
47};
48
49// Use "typename" rather than "class" here, just to be consistent
50template
51void FooBar() {
52 int some_array[] = {
53 5,
54 25,
55 7,
56 42
57 };
58
59 if (note == the_space_after_the_if) {
60 CallAfunction();
61 } else {
62 // Use a space after the // when commenting
63 }
64
65 // Comment directly above code when possible
66 if (some_condition) single_statement();
67
68 // Place a single space after the for loop semicolons
69 for (int i = 0; i != 25; ++i) {
70 // This is how we write loops
71 }
72
73 DoStuff(this, function, call, takes, up, multiple,
74 lines, like, this);
75
76 if (this || condition_takes_up_multiple &&
77 lines && like && this || everything ||
78 alright || then) {
79 }
80
81 switch (var) {
82 // No indentation for case label
83 case 1: {
84 int case_var = var + 3;
85 DoSomething(case_var);
86 break;
87 }
88 case 3:
89 DoSomething(var);
90 return;
91 // Always break, even after a return
92 break;
93
94 default:
95 // Yes, even break for the last case
96 break;
97 }
98
99 std::vector
100 you_can_declare,
101 a_few,
102 variables,
103 like_this;
104}
105
106}
107```
diff --git a/README.md b/README.md
index 79de09d98..e9bd8967e 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ For development discussion, please join us @ #citra on [freenode](http://webchat
8 8
9### Development 9### Development
10 10
11If you want to contribute please take a took at the [Coding Style](https://github.com/citra-emu/citra/wiki/Coding-Style), [Roadmap](https://github.com/citra-emu/citra/wiki/Roadmap) and [Developer Information](https://github.com/citra-emu/citra/wiki/Developer-Information) pages. You should as well contact any of the developers in the forum in order to know about the current state of the emulator. 11If you want to contribute please take a took at the [Contributor's Guide](CONTRIBUTING.md), [Roadmap](https://github.com/citra-emu/citra/wiki/Roadmap) and [Developer Information](https://github.com/citra-emu/citra/wiki/Developer-Information) pages. You should as well contact any of the developers in the forum in order to know about the current state of the emulator.
12 12
13### Building 13### Building
14 14