diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-09-23 15:50:30 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-09-28 10:15:33 +0200 |
commit | 86f56f3d4fd1629145af186bbdc97e122b63162f (patch) | |
tree | 0cec123ebfd5bfde2f48f65318b6421822d0d5c4 /telepathy-glib | |
parent | 9a7a5d94946cf98ca7e383097bc63cdba45483d5 (diff) | |
download | telepathy-glib-86f56f3d4fd1629145af186bbdc97e122b63162f.tar.gz |
util-internal: import 'finish' helper macros from Wocky
Diffstat (limited to 'telepathy-glib')
-rw-r--r-- | telepathy-glib/util-internal.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/telepathy-glib/util-internal.h b/telepathy-glib/util-internal.h index b1b0613ae..94a7cc0b9 100644 --- a/telepathy-glib/util-internal.h +++ b/telepathy-glib/util-internal.h @@ -26,4 +26,39 @@ GArray *_tp_quark_array_copy (const GQuark *quarks) G_GNUC_WARN_UNUSED_RESULT; void _tp_quark_array_merge (GArray *array, const GQuark *quarks, gssize n); +/* Copied from wocky/wocky-utils.h */ + +#define _tp_implement_finish_void(source, tag) \ + if (g_simple_async_result_propagate_error (\ + G_SIMPLE_ASYNC_RESULT (result), error)) \ + return FALSE; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT(source), tag), \ + FALSE); \ + return TRUE; + +#define _tp_implement_finish_copy_pointer(source, tag, copy_func, \ + out_param) \ + GSimpleAsyncResult *_simple; \ + _simple = (GSimpleAsyncResult *) result; \ + if (g_simple_async_result_propagate_error (_simple, error)) \ + return FALSE; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT (source), tag), \ + FALSE); \ + if (out_param != NULL) \ + *out_param = copy_func ( \ + g_simple_async_result_get_op_res_gpointer (_simple)); \ + return TRUE; + +#define _tp_implement_finish_return_copy_pointer(source, tag, copy_func) \ + GSimpleAsyncResult *_simple; \ + _simple = (GSimpleAsyncResult *) result; \ + if (g_simple_async_result_propagate_error (_simple, error)) \ + return NULL; \ + g_return_val_if_fail (g_simple_async_result_is_valid (result, \ + G_OBJECT (source), tag), \ + NULL); \ + return copy_func (g_simple_async_result_get_op_res_gpointer (_simple)); + #endif /* __TP_UTIL_INTERNAL_H__ */ |