diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-08-19 13:57:10 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2010-08-19 13:57:10 +0100 |
commit | 213bd1eab4e0dfbb0c033c5d8d56eb6343e35876 (patch) | |
tree | a439ae238cc528c3c5e466bb04981c4678718fe9 /clutter/clutter-debug.h | |
parent | 459a6bb24c880c21f71c37e99f04e801d117705d (diff) | |
download | clutter-213bd1eab4e0dfbb0c033c5d8d56eb6343e35876.tar.gz |
debug: Add a macro for checking debug flags
Diffstat (limited to 'clutter/clutter-debug.h')
-rw-r--r-- | clutter/clutter-debug.h | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/clutter/clutter-debug.h b/clutter/clutter-debug.h index d8fc63d3c..90f352ef1 100644 --- a/clutter/clutter-debug.h +++ b/clutter/clutter-debug.h @@ -38,51 +38,53 @@ typedef enum { #ifdef CLUTTER_ENABLE_DEBUG +#define CLUTTER_HAS_DEBUG(type) ((clutter_debug_flags & CLUTTER_DEBUG_##type) != FALSE) + #ifdef __GNUC__ -#define CLUTTER_NOTE(type,x,a...) G_STMT_START { \ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_##type)) \ - { g_message ("[" #type "] " G_STRLOC ": " x, ##a); } \ - } G_STMT_END - -#define CLUTTER_TIMESTAMP(type,x,a...) G_STMT_START { \ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_##type)) \ - { g_message ("[" #type "]" " %li:" G_STRLOC ": " \ - x, clutter_get_timestamp(), ##a); } \ - } G_STMT_END -#else + +/* Try the GCC extension for valists in macros */ +#define CLUTTER_NOTE(type,x,a...) G_STMT_START { \ + if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \ + g_message ("[" #type "] " G_STRLOC ": " x, ##a); \ + } } G_STMT_END + +#define CLUTTER_TIMESTAMP(type,x,a...) G_STMT_START { \ + if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \ + g_message ("[" #type "]" " %li:" G_STRLOC ": " \ + x, clutter_get_timestamp(), ##a); \ + } } G_STMT_END + +#else /* !__GNUC__ */ + /* Try the C99 version; unfortunately, this does not allow us to pass * empty arguments to the macro, which means we have to * do an intemediate printf. */ -#define CLUTTER_NOTE(type,...) G_STMT_START { \ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_##type)) \ - { \ - gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ - g_message ("[" #type "] " G_STRLOC ": %s",_fmt); \ - g_free (_fmt); \ - } \ - } G_STMT_END - -#define CLUTTER_TIMESTAMP(type,...) G_STMT_START { \ - if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_##type)) \ - { \ - gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ - g_message ("[" #type "]" " %li:" G_STRLOC ": %s", \ - clutter_get_timestamp(), _fmt); \ - g_free (_fmt); \ - } \ - } G_STMT_END -#endif - -#define CLUTTER_MARK() CLUTTER_NOTE(MISC, "== mark ==") -#define CLUTTER_DBG(x) { a } +#define CLUTTER_NOTE(type,...) G_STMT_START { \ + if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \ + gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ + g_message ("[" #type "] " G_STRLOC ": %s",_fmt); \ + g_free (_fmt); } } G_STMT_END + +#define CLUTTER_TIMESTAMP(type,...) G_STMT_START { \ + if (G_UNLIKELY (CLUTTER_HAS_DEBUG (type))) { \ + gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ + g_message ("[" #type "]" " %li:" G_STRLOC ": %s", \ + clutter_get_timestamp(), _fmt); \ + g_free (_fmt); \ + } } G_STMT_END + +#endif /* __GNUC__ */ + +#define CLUTTER_MARK() CLUTTER_NOTE(MISC, "== mark ==") +#define CLUTTER_DBG(x) { a } #define CLUTTER_GLERR() G_STMT_START { \ - if (clutter_debug_flags & CLUTTER_DEBUG_GL) \ - { GLenum _err = glGetError (); /* roundtrip */ \ - if (_err != GL_NO_ERROR) \ - g_warning (G_STRLOC ": GL Error %x", _err); \ - } } G_STMT_END + if (clutter_debug_flags & CLUTTER_DEBUG_GL) { \ + GLenum _err = glGetError (); /* roundtrip */ \ + if (_err != GL_NO_ERROR) \ + g_warning (G_STRLOC ": GL Error %x", _err); \ + } } G_STMT_END #else /* !CLUTTER_ENABLE_DEBUG */ @@ -92,6 +94,7 @@ typedef enum { #define CLUTTER_DBG(x) G_STMT_START { } G_STMT_END #define CLUTTER_GLERR() G_STMT_START { } G_STMT_END #define CLUTTER_TIMESTAMP(type,...) G_STMT_START { } G_STMT_END +#define CLUTTER_HAS_DEBUG(type) FALSE #endif /* CLUTTER_ENABLE_DEBUG */ |