-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHACKING
74 lines (57 loc) · 2.25 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
CenterIM 5 Hacking Documentation
Contents
--------
1. Coding Style
2. General Debugging
3. Valgrind Notes
1. Coding Style
---------------
- The clang-format tool should be used to format the code ('clang-format
--style=file -i FILE').
- Indentation is done by two spaces.
- Line length is limited to 80 characters.
- C++-style comments should be used and they must form full sentences:
// This is a comment.
- Names of classes use CamelNotation, methods use camelNotation(), variables use
common_c_naming. THIS_IS_A_CONST. An exception are libpurple/glib callbacks,
which use usual C naming-style (purple_print()).
- Example of a class definition:
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;
};
- Methods in each implementation file should be ordered as in the associated
header file.
- Methods that can be bound to a key should be prefixed with 'action', for
example, actionActivate().
- Methods connected to signals should use the 'on' prefix, for example,
onSelectionChanged().
- Singletons have all variables private, other classes should have all
variables protected.
2. General Debugging
--------------------
The '--enable-debug' configure option can be used to disable optimizations and
to produce a binary that contains debugging information.
The '--enable-strict' configure options enables extra compiler warnings. This
option should be always used during the development.
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
The final command should be run on an actual binary, not on a 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).
Setting the G_SLICE and G_DEBUG environment variables to the values mentioned
above turns off memory optimizations in Glib, which prevents some confusion for
Valgrind (https://live.gnome.org/Valgrind).