gobject: add GOBJECT_IF_DEBUG macro for debugging gobjects and gsignals.

historically, DEBUG_CODE(gtype.c) and IF_DEBUG(gobject.c, gsignal.c)
macros are used to support debugging messages about object bookkeeping
and signal emission.
DEBUG_CODE has never been used in gtype.c. IF_DEBUG, when used, must be
accompanied by an extra #ifdef G_ENABLE_DEBUG. this is cumbersome.

this patch add a new macro GOBJECT_IF_DEBUG based on DEBUG_CODE as
a replacement for both DEBUG_CODE and IF_DEBUG.

https://bugzilla.gnome.org/show_bug.cgi?id=729914
This commit is contained in:
Kang Hu
2014-05-25 22:32:17 +08:00
committed by Matthias Clasen
parent ec5397f9b0
commit 42dad59cc1
3 changed files with 28 additions and 28 deletions

View File

@@ -24,6 +24,24 @@
#include "gboxed.h"
#include "gclosure.h"
/*< private >
* GOBJECT_IF_DEBUG:
* @debug_type: Currently only OBJECTS and SIGNALS are supported.
* @code_block: Custom debug code.
*
* A convenience macro for debugging GObject.
* This macro is only used internally.
*/
#ifdef G_ENABLE_DEBUG
#define GOBJECT_IF_DEBUG(debug_type, code_block) \
G_STMT_START { \
if (_g_type_debug_flags & G_TYPE_DEBUG_ ## debug_type) \
{ code_block; } \
} G_STMT_END
#else /* !G_ENABLE_DEBUG */
#define GOBJECT_IF_DEBUG(debug_type, code_block)
#endif /* G_ENABLE_DEBUG */
G_BEGIN_DECLS
extern GTypeDebugFlags _g_type_debug_flags;