[telepathy-glib/master] Add a statement form of tp_verify_true, tp_verify_statement

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Aug 3 11:02:52 PDT 2009


This can be used anywhere g_assert() could.
---
 docs/reference/telepathy-glib-sections.txt |    1 +
 telepathy-glib/util.c                      |   12 ++++++++++++
 telepathy-glib/util.h                      |    2 ++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index cb8c352..e8b5db4 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1025,6 +1025,7 @@ TP_SVC_CONNECTION_MANAGER_GET_CLASS
 <INCLUDE>telepathy-glib/util.h</INCLUDE>
 tp_verify
 tp_verify_true
+tp_verify_statement
 tp_g_hash_table_update
 tp_g_ptr_array_contains
 tp_g_value_slice_new
diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c
index cc5699f..306f929 100644
--- a/telepathy-glib/util.c
+++ b/telepathy-glib/util.c
@@ -66,6 +66,18 @@
  */
 
 /**
+ * tp_verify_statement:
+ * @R: a requirement (constant expression) to be checked at compile-time
+ *
+ * Make an assertion at compile time, like C++0x's proposed static_assert
+ * keyword. If @R is determined to be true, there is no overhead at runtime;
+ * if @R is determined to be false, compilation will fail.
+ *
+ * This macro can be used anywhere that a statement would be allowed; it
+ * is equivalent to ((void) tp_verify_true (R)).
+ */
+
+/**
  * tp_g_ptr_array_contains:
  * @haystack: The pointer array to be searched
  * @needle: The pointer to look for
diff --git a/telepathy-glib/util.h b/telepathy-glib/util.h
index ce64857..1cd3df2 100644
--- a/telepathy-glib/util.h
+++ b/telepathy-glib/util.h
@@ -28,6 +28,8 @@
 
 #include <telepathy-glib/verify.h>
 
+#define tp_verify_statement(R) ((void) tp_verify_true (R))
+
 G_BEGIN_DECLS
 
 gboolean tp_g_ptr_array_contains (GPtrArray *haystack, gpointer needle);
-- 
1.5.6.5




More information about the telepathy-commits mailing list