1 #ifndef __JSON_DEBUG_H__ 2 #define __JSON_DEBUG_H__ 3 4 #include <glib.h> 5 6 G_BEGIN_DECLS 7 8 typedef enum { 9 JSON_DEBUG_PARSER = 1 << 0, 10 JSON_DEBUG_GOBJECT = 1 << 1, 11 JSON_DEBUG_PATH = 1 << 2, 12 JSON_DEBUG_NODE = 1 << 3 13 } JsonDebugFlags; 14 15 #define JSON_HAS_DEBUG(flag) (json_get_debug_flags () & JSON_DEBUG_##flag) 16 17 #ifdef JSON_ENABLE_DEBUG 18 19 # ifdef __GNUC__ 20 21 # define JSON_NOTE(type,x,a...) G_STMT_START { \ 22 if (JSON_HAS_DEBUG (type)) { \ 23 g_message ("[" #type "] " G_STRLOC ": " x, ##a); \ 24 } } G_STMT_END 25 26 # else 27 /* Try the C99 version; unfortunately, this does not allow us to pass 28 * empty arguments to the macro, which means we have to 29 * do an intemediate printf. 30 */ 31 # define JSON_NOTE(type,...) G_STMT_START { \ 32 if (JSON_HAS_DEBUG (type)) { \ 33 gchar * _fmt = g_strdup_printf (__VA_ARGS__); \ 34 g_message ("[" #type "] " G_STRLOC ": %s",_fmt); \ 35 g_free (_fmt); \ 36 } } G_STMT_END 37 38 # endif /* __GNUC__ */ 39 40 #else 41 42 #define JSON_NOTE(type,...) G_STMT_START { } G_STMT_END 43 44 #endif /* JSON_ENABLE_DEBUG */ 45 46 G_GNUC_INTERNAL 47 JsonDebugFlags json_get_debug_flags (void); 48 49 G_END_DECLS 50 51 #endif /* __JSON_DEBUG_H__ */ 52