4 The pixman coding style is close to cairo's with one exception: braces
5 go on their own line, rather than on the line of the if/while/for:
28 Each new level is indented four spaces:
33 This may be achieved with space characters or with a combination of
34 tab characters and space characters. Tab characters are interpreted as
36 Advance to the next column which is a multiple of 8.
42 In all names, words are separated with underscores. Do not use
43 CamelCase for any names.
45 Macros have ALL_CAPITAL_NAMES
47 Type names are in lower case and end with "_t". For example
50 Labels, functions and variables have lower case names.
56 Braces always go on their own line:
68 Rules for braces and substatements of if/while/for/do:
70 * If a substatement spans multiple lines, then there must be braces
73 * If the condition of an if/while/for spans multiple lines, then
74 braces must be used for the substatements.
76 * If one substatement of an if statement has braces, then the other
79 * Otherwise, don't add braces.
85 For comments either like this:
87 /* One line comment */
91 /* This is a multi-line comment
93 * It extends over multiple lines
96 Generally comments should say things that is clear from the code
97 itself. If too many comments say obvious things, then people will just
98 stop reading all comments, including the good ones.
104 * Put a single space after commas
106 * Put spaces around arithmetic operators such a +, -, *, /:
112 * Do not put spaces after the address-of operator, the * when used as
113 a pointer derefernce or the ! and ~ operators:
123 * Break up long lines (> ~80 characters) and use whitespace to align
124 things nicely. This is one way:
126 some_very_long_function name (
127 implementation, op, src, mask, dest,
128 src_x, src_y, mask_x, mask_y, dest_x, dest_y,
133 some_very_long_function_name (implementation, op,
140 * Separate logically distinct chunks with a single newline. This
141 obviously applies between functions, but also applies within a
142 function or block or structure definition.
144 * Use a newline after a block of variable declarations.
146 * Use a single space before a left parenthesis, except where the
147 standard will not allow it, (eg. when defining a parameterized macro).
149 * Don't eliminate newlines just because things would still fit on one
150 line. This breaks the expected visual structure of the code making
151 it much harder to read and understand:
153 if (condition) foo (); else bar (); /* Yuck! */
155 * Do eliminate trailing whitespace (space or tab characters) on any
156 line. Also, avoid putting initial or final blank lines into any
157 file, and never use multiple blank lines instead of a single blank
160 * Do enable the default git pre-commit hook that detect trailing
161 whitespace for you and help you to avoid corrupting cairo's tree
162 with it. Do that as follows:
164 chmod a+x .git/hooks/pre-commit
166 * You might also find the git-stripspace utility helpful which acts as
167 a filter to remove trailing whitespace as well as initial, final,
168 and duplicate blank lines.
174 Function definitions should take the following form:
177 my_function (argument)
182 If all the parameters to a function fit naturally on one line, format
183 them that way. Otherwise, put one argument on each line, adding
184 whitespace so that the parameter names are aligned with each other.
186 I.e., do either this:
189 short_arguments (const char *str, int x, int y, int z)
196 long_arguments (const char *char_star_arg,
198 double *double_star_arg,
207 Given the rules above, what is the best way to simplify one's life as
208 a code monkey? Get your editor to do most of the tedious work of
209 beautifying your code!
211 As a reward for reading this far, here are some mode lines for the more
214 * vim:sw=4:sts=4:ts=8:tw=78:fo=tcroq:cindent:cino=\:0,(0
215 * vim:isk=a-z,A-Z,48-57,_,.,-,>