summaryrefslogtreecommitdiffstats
path: root/lasso/utils.h
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:05:06 +0000
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-03-27 15:05:06 +0000
commita57841ce69d85d6012f3faea349b46be0d06592f (patch)
tree61f9ba925c6b2b1e032e69d0775ea1aa553e75f4 /lasso/utils.h
parentdfb0b91ed6d3c85aa7764de75d2e5298ed93ba22 (diff)
downloadlasso-a57841ce69d85d6012f3faea349b46be0d06592f.tar.gz
lasso-a57841ce69d85d6012f3faea349b46be0d06592f.tar.xz
lasso-a57841ce69d85d6012f3faea349b46be0d06592f.zip
Core: add new internal macro lasso_extract_node_or_fail
* lasso/utils.h: this new macro try to extract a field from a structre (or any left-hand-side value), try to typecheck it using 'LASSO_IS_XXX', if succesfull, the value is assigned to the variable given as first argument or we jump to the 'cleanup' goto label, setting the 4th argument as the current error code (value of variable 'rc').
Diffstat (limited to 'lasso/utils.h')
-rw-r--r--lasso/utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lasso/utils.h b/lasso/utils.h
index b047f19e..49e1b11f 100644
--- a/lasso/utils.h
+++ b/lasso/utils.h
@@ -292,6 +292,15 @@
#define lasso_transfer_gobject(dest, src) \
lasso_transfer_full(dest, src, gobject)
+/* Node extraction */
+#define lasso_extract_node_or_fail(to, from, kind, error) \
+ if (LASSO_IS_##kind(from)) { \
+ to = LASSO_##kind(from); \
+ } else { \
+ rc = error; \
+ goto cleanup; \
+ }
+
/* Bad param handling */
#define lasso_return_val_if_invalid_param(kind, name, val) \
g_return_val_if_fail(LASSO_IS_##kind(name), val)