4 This document defines coding style for GFXprim.
9 GFXprim is written in C. There is no C++ code in and I mean it. A few headers
10 do contain '#ifndef __cplusplus' so that you can interface GFXprim headers as
11 'extern C' without problems. If this doesn't work, let us know.
13 GFXprim follows mostly Linux Kernel coding style, see
14 'Documentation/CodingStyle' in the Linux Kernel source or follow this
15 link:http://www.kernel.org/doc/Documentation/CodingStyle[link] (it's funny and
16 enligthening reading).
18 .Indentation and whitespaces
20 * We use tabs for indentation and tab is eight spaces wide.
22 * Lines should be at most 80 chars long.
24 * No additional whitespaces (other than newline) at the end of line.
26 * Each file must end with newline (most editors do that automatically, beware
31 * Avoid tricky expressions if possible ;)
33 * Do not put multiple statements on a single line.
38 if (something) do_work();
48 * Each block that has more than one line should be enclosed in
51 Also if one part of if then else is enclosed in
52 curly braces the other one should be enclosed too.
59 else if (something_else)
75 * On the other hand do not use braces unnecesarily.
89 * The preffered way of writing switch is as follows:
104 TIP: You can use Linux Kernel 'scripts/checkpatch.pl' to check your code.
106 GFXprim Specific Rules
107 ^^^^^^^^^^^^^^^^^^^^^^
109 * Library external API uses CamelCase
110 ** Together with mandatory 'GP_' prefix.
111 ** For example 'GP_PixelType', 'GP_Context', etc.
112 ** We will not change that, get over it. (It could have been worse, trust me.)
114 * Basic library types are typedefed
115 ** We have 'GP_Size' and 'GP_Coord' integer types to better distinguish
116 roles of function parameters.
117 ** The basic structures are also typedefed so you can wite 'GP_Context'
118 instead of 'struct GP_Context'.
119 ** Other uses of typedef are frowned upon.
121 * When you add an externally visible symbol, i.e. new API function
122 please add its name into the corresponding file at 'build/syms/'. You may
123 also run the 'buld/check_symbols.sh' script to check that you haven't
124 accidentally exposed intenal only interfaces.
129 The Python parts of GFXprim follow mostly coding style outlined in
130 link:http://www.python.org/dev/peps/pep-0008/[PEP 8].
131 The major difference is that the default indent is 2 spaces.
132 All files should be ASCII unless required otherwise.
134 GFXPrim uses CamelCase as described in the C section.
135 The names are mostly derived from the corresponding C names without
137 All wrapped symbols of a module are available in the SWIG modules 'foo.c_foo'
138 (i.e. 'core.c_core').
140 Some number and enum types are typedeffed in C, but left as integers
141 in the Python interface.
142 All constants are available in 'foo.C' submodules (i.e. 'core.C')
145 Where this makes sense, functions should be available as methods of
146 an object (i.e. 'Context.Copy()' rather than 'Copy(context)'). Be Pythonic.