User Tools

Site Tools


devel:libdeng2_code_guidelines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

devel:libdeng2_code_guidelines [2012-03-29 08:42] (current)
Line 1: Line 1:
 +{{stub}}
 +
 +This article summarizes the coding conventions and practices used in Doomsday 2.0 (libdeng2 library).
 +
 +  *  more modular: core, legacy, data, network already present, more to come
 +  *  everything in "​include/​de"​ is the public API
 +  *  non-public headers go to the module'​s src dir
 +  *  Qt-like convenience includes with class name, e.g. "​include/​de/​Log"​
 +  *  copyright banner should be updated to match the new format in libdeng1 (with @file, @authors, <​small>​ GPL text)
 +  *  library-wide defines have a DENG2_ prefix (DENG2_USE_QT,​ DENG2_64BIT,​ DENG2_PUBLIC,​ DENG2_ASSERT)
 +  *  all C APIs should go to c_wrapper.h
 +  *  exports are marked with DENG2_PUBLIC (no .def files on Windows)
 +  *  all basic number types should use the d* typedefs in libdeng2.h
 +  *  the data module is important to know by heart: serialization,​ locking, byte array and string operations, time/date
 +  *  everything goes in "​namespace de"
 +  *  error situations are handled via exceptions (see usage of DENG2_ERROR,​ DENG2_SUB_ERROR through the modules)
 +  *  error exceptions need to include both function name and the error description (without a period in the end) -- see the existing throws in the code
 +  *  beware: exceptions cannot be allowed to reach to the libdeng1 one (kills the app immediately);​ they must be caught in C wrappers
 +  *  all non-trivial classes should use an opaque instance pointer (e.g., de::​Socket);​ however, it should be noted that signals & slots require the class declaration to be in a header file
 +  *  use of libdeng2 and Qt is fully allowed on libdeng1 side in .cpp files
 +  *  use of Qt container classes vs. STL: both are allowed, however Qt containers usually have copy-on-write semantics so making read-only copies is O(1)
 +  *  all log output (previous Con_Message/​Con_Printf/​printf/​fprintf) should use LOG_* (choose appropriate level) -- the level for including messages in the log output buffer is selected with LogBuffer::​enable()
 +  *  LOG_AS("​something"​) can be used for setting a persistent scope prefix for subsequent messages
  
devel/libdeng2_code_guidelines.txt ยท Last modified: 2012-03-29 08:42 (external edit)