~midori/midori/gtk3WebKit2only

« back to all changes in this revision

Viewing changes to HACKING

  • Committer: Christian Dywan
  • Date: 2007-12-16 22:20:24 UTC
  • Revision ID: git-v1:3bbd273a4f9e85a1d8380cb0924c875683fa3ad1
Tags: v0.0.14
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
It is 4 spaces, no tabs, preferrably at 80 columns per line.
 
2
 
 
3
The preferred coding style is explained by example.
 
4
 
 
5
Source file example:
 
6
 
 
7
    /*
 
8
       Copyright
 
9
       LICENSE TEXT
 
10
    */
 
11
 
 
12
    #include "foo.h"
 
13
 
 
14
    #include "bar.h"
 
15
 
 
16
    #include <glib.h>
 
17
 
 
18
    void foobar(FooEnum bar, const gchar* foo)
 
19
    {
 
20
        if(!foo)
 
21
            return;
 
22
 
 
23
        #ifdef BAR_STRICT
 
24
        if(bar == FOO_N)
 
25
        {
 
26
            g_print("illegal value for 'bar'.\n");
 
27
            return;
 
28
        }
 
29
        #endif
 
30
 
 
31
        // this is an example
 
32
        gint n;
 
33
        switch(bar)
 
34
        {
 
35
        case FOO_FOO:
 
36
            n = bar + 1;
 
37
            break;
 
38
        case FOO_BAR:
 
39
            n = bar + 10;
 
40
            break;
 
41
        default:
 
42
            n = 1;
 
43
        }
 
44
 
 
45
        guint i;
 
46
        for(i = 0; i < n; i++)
 
47
        {
 
48
            g_print("%s\n", foo);
 
49
        }
 
50
    }
 
51
 
 
52
Header file example:
 
53
 
 
54
    /*
 
55
       Copyright
 
56
       LICENSE TEXT
 
57
    */
 
58
 
 
59
    #ifndef __FOO_H__
 
60
    #define __FOO_H__ 1
 
61
 
 
62
    #ifdef HAVE_BAR_H
 
63
        #define BAR_STRICT
 
64
    #endif
 
65
 
 
66
    // -- Types
 
67
 
 
68
    typedef enum
 
69
    {
 
70
        FOO_FOO,
 
71
        FOO_BAR,
 
72
        FOO_N
 
73
    } FooEnum;
 
74
 
 
75
    typedef struct
 
76
    {
 
77
        FooEnum fooBar;
 
78
    } FooStruct;
 
79
 
 
80
    // -- Declarations
 
81
 
 
82
    void
 
83
    foobar(FooEnum, const gchar*);
 
84
 
 
85
    #endif /* !__FOO_H__ */