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))) 
)

Add file describing the coding style
Add file describing the coding style
