1
0
Fork 0
mutter-performance-source/doc/CODING_STYLE
Robert Bragg 54735dec84 Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.

Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.

Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.

So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.

Instead of gsize we now use size_t

For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-08-06 14:27:39 +01:00

50 lines
1.7 KiB
Text

Cogl Coding Style
--------------------
This document is intended to be a short description of the preferred
coding style to be used for the Cogl source code.
Coding style is a matter of consistency, readability and maintainance;
coding style is also completely arbitrary and a matter of taste. This
document will use examples at the very least to provide authoritative
and consistent answers to common questions regarding the coding style,
and will also try to identify the allowed exceptions.
The Cogl coding style is currently defined relative to the Clutter
coding style, so please first read clutter/docs/CODING_STYLE.
Differences to the Clutter coding style:
+ Headers
Cogl headers are not exempt from the 80 characters limit as they are in
Clutter. Function prototypes should not be arranged into vertical
columns but should instead look somthing like this:
void
my_function (CoglType type,
CoglType *a_pointer,
CoglType another_type);
+ Types
Avoid the use of redundant glib typedefs and wherever possible simply
use ANSI C/c99 types.
The following types should not be used:
gint, guint, gfloat, gdouble, glong, gulong, gchar, guchar,
guint{8,16,32} or gint{8,16,32}
Instead use:
int, unsigned int, float, double, long, unsigned long, char,
unsigned char, uint{8,16,32}_t and int{8,16,32}_t
Use CoglBool for boolean types.
When ever you need a byte size type for dealing with pixel data then
uint8_t should be used.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.