add a 'void* extra' parameter to the INVARIANT macros
authorChristian Thaeter <ct@pipapo.org>
Sun, 18 Apr 2010 20:09:38 +0000 (22:09 +0200)
committerChristian Thaeter <ct@pipapo.org>
Sun, 18 Apr 2010 20:09:38 +0000 (22:09 +0200)
Same as the previous commit but for invariants.

src/nobug.h
tests/test_nobug.c

index 42056de..323b0ac 100644 (file)
 //assertions
 // 'invariant_context' must be passed in
 */
 //assertions
 // 'invariant_context' must be passed in
 */
-#define NOBUG_INVARIANT(type, pointer, depth)                                   \
+#define NOBUG_INVARIANT(type, pointer, depth, extra)                            \
   NOBUG_IF_ALPHA(                                                               \
                  NOBUG_WHEN (NOBUG_SCOPE_UNCHECKED,                             \
                              NOBUG_CAT(type,_invariant)(pointer, depth,         \
   NOBUG_IF_ALPHA(                                                               \
                  NOBUG_WHEN (NOBUG_SCOPE_UNCHECKED,                             \
                              NOBUG_CAT(type,_invariant)(pointer, depth,         \
-                                                        NOBUG_CONTEXT)          \
+                                                        NOBUG_CONTEXT, extra)   \
                              )                                                  \
   )
 
 
                              )                                                  \
   )
 
 
-#define NOBUG_INVARIANT_IF(when, type, pointer, depth)          \
+#define NOBUG_INVARIANT_IF(when, type, pointer, depth, extra)   \
   NOBUG_IF_ALPHA(                                               \
     NOBUG_WHEN (NOBUG_SCOPE_UNCHECKED,                          \
       NOBUG_WHEN (when,                                         \
                   NOBUG_CAT(type,_invariant)(pointer, depth,    \
   NOBUG_IF_ALPHA(                                               \
     NOBUG_WHEN (NOBUG_SCOPE_UNCHECKED,                          \
       NOBUG_WHEN (when,                                         \
                   NOBUG_CAT(type,_invariant)(pointer, depth,    \
-                                             NOBUG_CONTEXT)     \
+                                             NOBUG_CONTEXT,     \
+                                             extra)             \
                   )                                             \
   ))
 
                   )                                             \
   ))
 
index 6d27381..fda98a6 100644 (file)
@@ -7,14 +7,14 @@ struct foo
   struct foo* bar;
 };
 
   struct foo* bar;
 };
 
-void foo_invariant (struct foo* self, int depth, const struct nobug_context invariant_context)
+void foo_invariant (struct foo* self, int depth, const struct nobug_context invariant_context, void* extra)
 {
   if (!depth) return;
 
   INVARIANT_ASSERT(self->b != 8);
 
   if (self->bar)
 {
   if (!depth) return;
 
   INVARIANT_ASSERT(self->b != 8);
 
   if (self->bar)
-    foo_invariant (self->bar, depth-1, invariant_context);
+    foo_invariant (self->bar, depth-1, invariant_context, extra);
 }
 
 void nobug_foo_dump (const struct foo* self, const int depth, const struct nobug_context dump_context, void* extra)
 }
 
 void nobug_foo_dump (const struct foo* self, const int depth, const struct nobug_context dump_context, void* extra)
@@ -89,7 +89,7 @@ TEST(8)
   f.b = c;
   f.bar = NULL;
 
   f.b = c;
   f.bar = NULL;
 
-  INVARIANT(foo, &f, 2);
+  INVARIANT(foo, &f, 2, NULL);
 }
 
 
 }