Difference between revisions of "Code Formatting Conventions"

Jump to navigation Jump to search
m
fine-tuning
m (fine-tuning)
Line 1: Line 1:
== 1. Use common sense ==
== Use common sense ==


These are conventions which we try to follow when writing code for ScummVM. They are this way mainly for reasons of taste, however, sticking to a common set of formatting rules also makes it slightly easier to read through our sources. If you want to submit patches, please try to follow these rules.  
These are conventions which we try to follow when writing code for ScummVM. They are this way mainly for reasons of taste, however, sticking to a common set of formatting rules also makes it slightly easier to read through our sources. If you want to submit patches, please try to follow these rules.  
Line 7: Line 7:
In the following examples tabs are replaced by spaces for visual consistency with the Code Formatting Conventions.
In the following examples tabs are replaced by spaces for visual consistency with the Code Formatting Conventions.


== 2. Hugging braces ==
== Hugging braces ==


Braces in your code should look like the following example:
Braces in your code should look like the following example:
Line 25: Line 25:
Did you see the {}'s on that?
Did you see the {}'s on that?


== 3. Tab indents, with tabstop at four spaces ==
== Tab indents, with tabstop at four spaces ==


Says it all, really.
Says it all, really.


== 4. Whitespaces ==
== Whitespaces ==


'''Conventional operators surrounded by a space character'''
'''Conventional operators surrounded by a space character'''
Line 78: Line 78:
</pre>
</pre>


== 5. Switch / Case constructs ==
== Switch / Case constructs ==


<pre>
<pre>
Line 94: Line 94:
</pre>
</pre>


== 6. Naming ==
== Naming ==


'''Constants'''
'''Constants'''
Line 134: Line 134:
</pre>
</pre>


== 7. Special comments ==
== Special comments ==


The following goes slightly beyond code formatting: We use certain keywords (together with an explanatory text) to mark certains sections of our code. In particular:
The following goes slightly beyond code formatting: We use certain keywords (together with an explanatory text) to mark certains sections of our code. In particular:

Navigation menu