-
Notifications
You must be signed in to change notification settings - Fork 2
/
HACKING
81 lines (61 loc) · 2.05 KB
/
HACKING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
CenterIM 5 Hacking Documentation
Contents
--------
1. Code Style
2. General Debugging
3. Valgrind Notes
1. Code Style
-------------
- No tabs, two spaces indenting.
- Line length limited to 78 characters.
- Comments:
// one line comment
/* Multiline
* comment. */
- Names of classes and methods use CamelNotation, variables use
common_c_naming. THIS_IS_A_CONST. There is an exception, libpurple/glib
callbacks use common C naming too.
- Example of class declaration:
class MyClass
: public OtherClass
{
public:
// enums and typedefs first,
// then variables,
// methods last
/**
* Doxygen comment.
*/
virtual size_t GetLinesCount() const { return lines_count; }
protected:
size_t lines_count;
private:
};
- Order methods in an implementation file according to a header file.
- Methods that can be bound to a key are prefixed with 'Action', for example,
ActionActivate().
- Methods connected to signals should use 'On' prefix, for example,
OnSelectionChanged().
- Singletons have got all variables private, other classes should have all
variables protected.
2. General Debugging
--------------------
Use the '--enable-debug' configure option to disable optimizations and to
enable producing of binary with debugging information.
Use the '--enable-strict' configure option to enable extra compiler warnings.
3. Valgrind Notes
-----------------
% export GLIBCXX_FORCE_NEW=1
% export G_DEBUG=gc-friendly
% export G_SLICE=always-malloc
% valgrind --leak-check=full --child-silent-after-fork=yes \
--log-file=cim5.log --track-fds=yes centerim5
Make sure you don't run this command on libtool's binary wrapper.
GLIBCXX_FORCE_NEW forces libstdc++ allocator to use new() and delete() calls
instead of using memory pools
(http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_allocators.html).
G_SLICE and G_DEBUG env vars make sure to turn off glib's memory
optimizations, so that they do not confuse Valgrind
(https://live.gnome.org/Valgrind).
There is currently no suppresion list, though you can use at least the list
from the Pidgin project.