summaryrefslogtreecommitdiff
path: root/docs/codingstyle.txt
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2008-05-08 16:36:22 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.co.uk>2008-05-08 16:36:22 -0400
commitbdb4b6e5691b5e1c93a0b9fcc5f39ad6ef444936 (patch)
tree29069c564240a47e7237fe5aaa8ce0d0f6290f8c /docs/codingstyle.txt
parent290d8a6072606acc6dbf9c184a9b2e2230d2e7da (diff)
downloadfarstream-bdb4b6e5691b5e1c93a0b9fcc5f39ad6ef444936.tar.gz
Add file describing the coding style
Diffstat (limited to 'docs/codingstyle.txt')
-rw-r--r--docs/codingstyle.txt113
1 files changed, 113 insertions, 0 deletions
diff --git a/docs/codingstyle.txt b/docs/codingstyle.txt
new file mode 100644
index 00000000..0236f170
--- /dev/null
+++ b/docs/codingstyle.txt
@@ -0,0 +1,113 @@
+This page describes the Farsight2 coding style. Respect it or die.
+
+It is a copy of
+http://farsight.freedesktop.org/wiki/Fs2CodingStyle
+
+They should both be in sync
+
+
+
+Loosely based on GNU style C.
+
+Max line width 80.
+
+All long lines wrapped with 4 space indentation.
+
+Spaces after all procedural calls (includes macros).
+
+Function names and variables names use underscore word separators. All GObject methods are prefixed with the appropriate prefix for the object.
+
+Typenames are in camelcase.
+
+NO TABS!
+
+Base indent unit is 2 spaces.
+
+==== Function prototypes ====
+
+The first parameter is on the same line as the function only if the function is a method.
+
+static void farsight_rtp_stream_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+==== Function declarations ====
+
+The first parameter is on the same line as the function only if the function is a method.
+
+static void
+farsight_rtp_stream_get_property (GObject * object,
+ guint prop_id,
+ GValue * value,
+ GParamSpec * pspec)
+{
+}
+
+==== If/else/while/for/do/struct/switch/etc ====
+
+if (condition)
+{
+ die ();
+}
+else
+{
+ die ();
+}
+
+For blocks that only contain one statement, the opening/closing brackets can be omitted. But this can only be done if all the blocks in a statement contain only one statement. This is an ILLEGAL example :
+
+if (condition)
+ die ();
+else
+{
+ die ();
+ die_again ();
+}
+
+
+==== Breaks and boolean operators ====
+
+if (self->priv->main_pipeline && src_in_pipeline
+ || !self->priv->your_mama)
+{
+}
+
+==== Pointer declarations ====
+
+Type *var;
+
+==== Switch ====
+
+switch (var)
+{
+ case 4:
+ die ();
+ break;
+ case 5:
+ die ();
+}
+
+==== Casting ====
+
+FarsightRTPStream *self = (FarsightRTPStream *) stream;
+
+==== Emacs mode ====
+
+(defun farsight2-c-mode ()
+ "C mode with farsight2 style"
+ (interactive)
+ (c-mode)
+ (c-set-style "GNU")
+ (setq tab-width 8)
+ (setq indent-tabs-mode nil)
+ (setq c-basic-offset 2)
+ (setq c-tab-always-indent nil)
+ (setq show-trailing-whitespace 't)
+ (c-set-offset 'case-label 2)
+ (c-set-offset 'arglist-intro 4)
+ (c-set-offset 'statement-cont 4)
+ (c-set-offset 'substatement-open 0)
+ (c-set-offset 'arglist-cont-nonempty 4)
+ (setq c-cleanup-list (quote (brace-else-brace brace-elseif-brace space-before-funcall)))
+)