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