add a 'void* extra' parameter to the DUMP macros
authorChristian Thaeter <ct@pipapo.org>
Thu, 8 Apr 2010 17:31:57 +0000 (19:31 +0200)
committerChristian Thaeter <ct@pipapo.org>
Thu, 8 Apr 2010 17:31:57 +0000 (19:31 +0200)
This breaks code using the dump macros, fix it by adding a void* extra to
the nobug_*_dump functions and pass NULL around.

Library compatibility is not broken.

src/nobug.h
tests/test_nobug.c

index 29c1f89..42056de 100644 (file)
 /*TODO dump-level for flags instead limits[0]*/
 /*
 //dumpmacros PARA DUMP; DUMP; dumping datastructures
 /*TODO dump-level for flags instead limits[0]*/
 /*
 //dumpmacros PARA DUMP; DUMP; dumping datastructures
-//dumpmacros  DUMP(flag, type, pointer, depth)
-//dumpmacros  DUMP_IF(when, flag, type, pointer, depth)
+//dumpmacros  DUMP(flag, type, pointer, depth, extra)
+//dumpmacros  DUMP_IF(when, flag, type, pointer, depth, extra)
 //dumpmacros
 //dumpmacros This macros call a datastructure dump of the object (`pointer`) in question.
 //dumpmacros `DUMP` is only available in *ALPHA* and *BETA* builds, `DUMP_IF` is also
 //dumpmacros enabled for the RELEASE builds.
 //dumpmacros
 //dumpmacros
 //dumpmacros This macros call a datastructure dump of the object (`pointer`) in question.
 //dumpmacros `DUMP` is only available in *ALPHA* and *BETA* builds, `DUMP_IF` is also
 //dumpmacros enabled for the RELEASE builds.
 //dumpmacros
+//dumpmacros `extra` is a void* which is transparently passed around
+//dumpmacros
 */
 */
-#define NOBUG_DUMP(flag, type, pointer, depth)                                                          \
-  NOBUG_IF_NOT_RELEASE(                                                                                 \
-                       NOBUG_WHEN (NOBUG_DUMP_LEVEL >= NOBUG_FLAG(flag).limits[NOBUG_LOG_TARGET],       \
-                                   NOBUG_CAT3 (nobug_, type, _dump)(pointer, depth,  NOBUG_CONTEXT)     \
-                                   )                                                                    \
+#define NOBUG_DUMP(flag, type, pointer, depth, extra)                                                           \
+  NOBUG_IF_NOT_RELEASE(                                                                                         \
+                       NOBUG_WHEN (NOBUG_DUMP_LEVEL >= NOBUG_FLAG(flag).limits[NOBUG_LOG_TARGET],               \
+                                   NOBUG_CAT3 (nobug_, type, _dump)(pointer, depth,  NOBUG_CONTEXT, extra)      \
+                                   )                                                                            \
   )
 
   )
 
-#define NOBUG_DUMP_IF(when, flag, type, pointer, depth)                                 \
-  NOBUG_WHEN (NOBUG_DUMP_LEVEL >= NOBUG_FLAG(flag).limits[NOBUG_LOG_TARGET] && when,    \
-              NOBUG_CAT3 (nobug_, type, _dump)(pointer, depth, NOBUG_CONTEXT)           \
+#define NOBUG_DUMP_IF(when, flag, type, pointer, depth, extra)                                  \
+  NOBUG_WHEN (NOBUG_DUMP_LEVEL >= NOBUG_FLAG(flag).limits[NOBUG_LOG_TARGET] && when,            \
+              NOBUG_CAT3 (nobug_, type, _dump)(pointer, depth, NOBUG_CONTEXT, extra)            \
   )
 
 
   )
 
 
index 7248d0a..6d27381 100644 (file)
@@ -17,13 +17,13 @@ void foo_invariant (struct foo* self, int depth, const struct nobug_context inva
     foo_invariant (self->bar, depth-1, invariant_context);
 }
 
     foo_invariant (self->bar, depth-1, invariant_context);
 }
 
-void nobug_foo_dump (const struct foo* self, const int depth, const struct nobug_context dump_context)
+void nobug_foo_dump (const struct foo* self, const int depth, const struct nobug_context dump_context, void* extra)
 {
   if (self && depth)
     {
       DUMP_LOG("dump b is %d", self->b);
 
 {
   if (self && depth)
     {
       DUMP_LOG("dump b is %d", self->b);
 
-      nobug_foo_dump (self->bar, depth-1, dump_context);
+      nobug_foo_dump (self->bar, depth-1, dump_context, extra);
     }
 }
 
     }
 }
 
@@ -99,7 +99,7 @@ TEST(11)
   f.b = c;
   f.bar = NULL;
 
   f.b = c;
   f.bar = NULL;
 
-  DUMP(test, foo, &f, 2);
+  DUMP(test, foo, &f, 2, NULL);
 }
 
 
 }