diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-03 11:50:00 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-03 15:47:04 +0100 |
commit | 89daca7d915fff2d7e60c88360165503f7fbc34a (patch) | |
tree | 3edc5d1a51a21cc0398c9629550187d8746b1e5d | |
parent | 56d7499fda89d7c81c93142f148db1511c338987 (diff) |
Move tp_g_value_slice_* family to dbus library
Replace a couple of tp_dbus_check_valid_object_path calls with
g_variant_is_object_path to avoid having to move the former
into the dbus or core library.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76855
Reviewed-by: Xavier Claessens
38 files changed, 655 insertions, 553 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt index 52eaee84f..def44a9e4 100644 --- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt @@ -1291,22 +1291,6 @@ TP_SVC_CONNECTION_MANAGER_GET_CLASS tp_g_hash_table_update tp_g_ptr_array_contains tp_g_ptr_array_extend -tp_g_value_slice_new -tp_g_value_slice_new_boolean -tp_g_value_slice_new_boxed -tp_g_value_slice_new_static_boxed -tp_g_value_slice_new_take_boxed -tp_g_value_slice_new_double -tp_g_value_slice_new_int -tp_g_value_slice_new_int64 -tp_g_value_slice_new_string -tp_g_value_slice_new_static_string -tp_g_value_slice_new_take_string -tp_g_value_slice_new_uint -tp_g_value_slice_new_uint64 -tp_g_value_slice_new_byte -tp_g_value_slice_free -tp_g_value_slice_dup tp_str_empty tp_strdiff tp_mixin_offset_cast @@ -1339,6 +1323,33 @@ tp_value_array_free </SECTION> <SECTION> +<FILE>sliced-gvalue</FILE> +<TITLE>sliced-gvalue</TITLE> +<INCLUDE>telepathy-glib/telepathy-glib-dbus.h</INCLUDE> +tp_g_value_slice_new +tp_g_value_slice_new_boolean +tp_g_value_slice_new_boxed +tp_g_value_slice_new_static_boxed +tp_g_value_slice_new_take_boxed +tp_g_value_slice_new_double +tp_g_value_slice_new_int +tp_g_value_slice_new_int64 +tp_g_value_slice_new_string +tp_g_value_slice_new_static_string +tp_g_value_slice_new_take_string +tp_g_value_slice_new_uint +tp_g_value_slice_new_uint64 +tp_g_value_slice_new_byte +tp_g_value_slice_free +tp_g_value_slice_dup +tp_g_value_slice_new_bytes +tp_g_value_slice_new_take_bytes +tp_g_value_slice_new_object_path +tp_g_value_slice_new_static_object_path +tp_g_value_slice_new_take_object_path +</SECTION> + +<SECTION> <FILE>gnio-util</FILE> <TITLE>gnio-util</TITLE> <INCLUDE>telepathy-glib/telepathy-glib.h</INCLUDE> @@ -1924,11 +1935,6 @@ tp_dbus_check_valid_bus_name tp_dbus_check_valid_interface_name tp_dbus_check_valid_member_name tp_dbus_check_valid_object_path -tp_g_value_slice_new_bytes -tp_g_value_slice_new_take_bytes -tp_g_value_slice_new_object_path -tp_g_value_slice_new_static_object_path -tp_g_value_slice_new_take_object_path <SUBSECTION> tp_dbus_connection_release_name tp_dbus_connection_request_name diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am index 25aa52c9d..32c02c8bb 100644 --- a/telepathy-glib/Makefile.am +++ b/telepathy-glib/Makefile.am @@ -141,6 +141,7 @@ tpgdbusinclude_HEADERS = \ cli-misc.h \ gtypes.h \ interfaces.h \ + sliced-gvalue.h \ svc-account.h \ svc-account-manager.h \ svc-call.h \ @@ -205,6 +206,7 @@ libtelepathy_glib_dbus_internal_la_SOURCES = \ cli-misc.c \ gtypes.c \ interfaces.c \ + sliced-gvalue.c \ value-array.c \ $(NULL) diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c index a5289a594..a28b4378b 100644 --- a/telepathy-glib/account-channel-request.c +++ b/telepathy-glib/account-channel-request.c @@ -86,6 +86,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/simple-handler.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/variant-util.h> diff --git a/telepathy-glib/account-request.c b/telepathy-glib/account-request.c index 183eb55ed..d7b92f920 100644 --- a/telepathy-glib/account-request.c +++ b/telepathy-glib/account-request.c @@ -27,6 +27,7 @@ #include <telepathy-glib/cli-misc.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/value-array.h> #include <telepathy-glib/client-factory.h> diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index d34ebb9ea..4f62a8f26 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -35,6 +35,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index 3ca13dd68..757973f7d 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -247,6 +247,7 @@ #include <telepathy-glib/exportable-channel.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-connection.h> #include <telepathy-glib/svc-generic.h> #include <telepathy-glib/util.h> diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c index d9ed45aaf..ae5987645 100644 --- a/telepathy-glib/base-contact-list.c +++ b/telepathy-glib/base-contact-list.c @@ -28,6 +28,7 @@ #include <telepathy-glib/handle-repo-dynamic.h> #include <telepathy-glib/handle-repo-static.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-connection.h> #include <telepathy-glib/util.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/base-protocol.c b/telepathy-glib/base-protocol.c index 6a2595c2b..847d3ee1a 100644 --- a/telepathy-glib/base-protocol.c +++ b/telepathy-glib/base-protocol.c @@ -27,6 +27,7 @@ #include <telepathy-glib/channel-manager.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-generic.h> #include <telepathy-glib/svc-protocol.h> #include <telepathy-glib/telepathy-glib.h> diff --git a/telepathy-glib/base-room-config.c b/telepathy-glib/base-room-config.c index 3e48ccc67..bbda75d7e 100644 --- a/telepathy-glib/base-room-config.c +++ b/telepathy-glib/base-room-config.c @@ -24,6 +24,7 @@ #include <telepathy-glib/dbus-properties-mixin.h> #include <telepathy-glib/dbus.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-channel.h> #include <telepathy-glib/util.h> diff --git a/telepathy-glib/channel-dispatch-operation.c b/telepathy-glib/channel-dispatch-operation.c index 3ca2d9c07..82bad84cb 100644 --- a/telepathy-glib/channel-dispatch-operation.c +++ b/telepathy-glib/channel-dispatch-operation.c @@ -34,6 +34,7 @@ #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-internal.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/variant-util.h> diff --git a/telepathy-glib/channel.c b/telepathy-glib/channel.c index 39c8ca8ea..17e281da6 100644 --- a/telepathy-glib/channel.c +++ b/telepathy-glib/channel.c @@ -30,6 +30,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/util-internal.h> diff --git a/telepathy-glib/cm-message.c b/telepathy-glib/cm-message.c index fd57e9bb7..68f601d8d 100644 --- a/telepathy-glib/cm-message.c +++ b/telepathy-glib/cm-message.c @@ -37,6 +37,7 @@ #include <telepathy-glib/dbus.h> #include <telepathy-glib/gtypes.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> G_DEFINE_TYPE (TpCMMessage, tp_cm_message, TP_TYPE_MESSAGE) diff --git a/telepathy-glib/dbus-properties-mixin.c b/telepathy-glib/dbus-properties-mixin.c index 555c3cc19..c834fb617 100644 --- a/telepathy-glib/dbus-properties-mixin.c +++ b/telepathy-glib/dbus-properties-mixin.c @@ -24,6 +24,7 @@ #include "telepathy-glib/dbus-properties-mixin-internal.h" #include <telepathy-glib/errors.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-generic.h> #include <telepathy-glib/util.h> diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c index 6538793b5..8916da024 100644 --- a/telepathy-glib/dbus.c +++ b/telepathy-glib/dbus.c @@ -67,6 +67,7 @@ #include <telepathy-glib/errors.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/proxy.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-interface-skeleton-internal.h> #include <telepathy-glib/util.h> @@ -509,121 +510,6 @@ tp_dbus_check_valid_object_path (const gchar *path, GError **error) } /** - * tp_g_value_slice_new_bytes: (skip) - * @length: number of bytes to copy - * @bytes: location of an array of bytes to be copied (this may be %NULL - * if and only if length is 0) - * - * Slice-allocate a #GValue containing a byte-array, using - * tp_g_value_slice_new_boxed(). This function is convenient to use when - * constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %DBUS_TYPE_G_UCHAR_ARRAY whose value is a copy - * of @length bytes from @bytes, to be freed with tp_g_value_slice_free() or - * g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_bytes (guint length, - gconstpointer bytes) -{ - GArray *arr; - - g_return_val_if_fail (length == 0 || bytes != NULL, NULL); - arr = g_array_sized_new (FALSE, FALSE, 1, length); - - if (length > 0) - g_array_append_vals (arr, bytes, length); - - return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_UCHAR_ARRAY, arr); -} - -/** - * tp_g_value_slice_new_take_bytes: (skip) - * @bytes: a non-NULL #GArray of guchar, ownership of which will be taken by - * the #GValue - * - * Slice-allocate a #GValue containing @bytes, using - * tp_g_value_slice_new_boxed(). This function is convenient to use when - * constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %DBUS_TYPE_G_UCHAR_ARRAY whose value is - * @bytes, to be freed with tp_g_value_slice_free() or - * g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_take_bytes (GArray *bytes) -{ - g_return_val_if_fail (bytes != NULL, NULL); - return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_UCHAR_ARRAY, bytes); -} - -/** - * tp_g_value_slice_new_object_path: (skip) - * @path: a valid D-Bus object path which will be copied - * - * Slice-allocate a #GValue containing an object path, using - * tp_g_value_slice_new_boxed(). This function is convenient to use when - * constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is a copy - * of @path, to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_object_path (const gchar *path) -{ - g_return_val_if_fail (tp_dbus_check_valid_object_path (path, NULL), NULL); - return tp_g_value_slice_new_boxed (DBUS_TYPE_G_OBJECT_PATH, path); -} - -/** - * tp_g_value_slice_new_static_object_path: (skip) - * @path: a valid D-Bus object path which must remain valid forever - * - * Slice-allocate a #GValue containing an object path, using - * tp_g_value_slice_new_static_boxed(). This function is convenient to use when - * constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is @path, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_static_object_path (const gchar *path) -{ - g_return_val_if_fail (tp_dbus_check_valid_object_path (path, NULL), NULL); - return tp_g_value_slice_new_static_boxed (DBUS_TYPE_G_OBJECT_PATH, path); -} - -/** - * tp_g_value_slice_new_take_object_path: (skip) - * @path: a valid D-Bus object path which will be freed with g_free() by the - * returned #GValue (the caller must own it before calling this function, but - * no longer owns it after this function returns) - * - * Slice-allocate a #GValue containing an object path, using - * tp_g_value_slice_new_take_boxed(). This function is convenient to use when - * constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is @path, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_take_object_path (gchar *path) -{ - g_return_val_if_fail (tp_dbus_check_valid_object_path (path, NULL), NULL); - return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_OBJECT_PATH, path); -} - -/** * tp_asv_new: (skip) * @first_key: the name of the first key (or NULL) * @...: type and value for the first key, followed by a NULL-terminated list diff --git a/telepathy-glib/dbus.h b/telepathy-glib/dbus.h index 835512c36..f3af6c739 100644 --- a/telepathy-glib/dbus.h +++ b/telepathy-glib/dbus.h @@ -58,21 +58,6 @@ gboolean tp_dbus_check_valid_member_name (const gchar *name, gboolean tp_dbus_check_valid_object_path (const gchar *path, GError **error); -/* The scanner warns about these, but they're skipped anyway. - * See GNOME bug#656743 */ -#ifndef __GI_SCANNER__ -GValue *tp_g_value_slice_new_bytes (guint length, gconstpointer bytes) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_take_bytes (GArray *bytes) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_object_path (const gchar *path) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_static_object_path (const gchar *path) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_take_object_path (gchar *path) - G_GNUC_WARN_UNUSED_RESULT; -#endif /* __GI_SCANNER__ */ - #define tp_asv_size(asv) _tp_asv_size_inline (asv) static inline guint diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c index 17cbd81f5..7e4def777 100644 --- a/telepathy-glib/file-transfer-channel.c +++ b/telepathy-glib/file-transfer-channel.c @@ -106,6 +106,7 @@ #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-subclass.h> #include <telepathy-glib/proxy-internal.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/util.h> #include <telepathy-glib/variant-util-internal.h> diff --git a/telepathy-glib/gnio-util.c b/telepathy-glib/gnio-util.c index 31466543f..ce4137591 100644 --- a/telepathy-glib/gnio-util.c +++ b/telepathy-glib/gnio-util.c @@ -43,6 +43,7 @@ #include <telepathy-glib/util.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/errors.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/group-mixin.c b/telepathy-glib/group-mixin.c index f299feff9..1d05e15c2 100644 --- a/telepathy-glib/group-mixin.c +++ b/telepathy-glib/group-mixin.c @@ -69,6 +69,7 @@ #include <telepathy-glib/errors.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-channel.h> #define DEBUG_FLAG TP_DEBUG_GROUPS diff --git a/telepathy-glib/message-mixin.c b/telepathy-glib/message-mixin.c index 92ba0d88a..5adc0bf0c 100644 --- a/telepathy-glib/message-mixin.c +++ b/telepathy-glib/message-mixin.c @@ -76,6 +76,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/message-internal.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-channel.h> #define DEBUG_FLAG TP_DEBUG_IM diff --git a/telepathy-glib/message.c b/telepathy-glib/message.c index 01099dbcb..1c17e5359 100644 --- a/telepathy-glib/message.c +++ b/telepathy-glib/message.c @@ -40,6 +40,7 @@ #include <telepathy-glib/cm-message.h> #include <telepathy-glib/dbus.h> #include <telepathy-glib/gtypes.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/variant-util.h> diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c index 789c1c4e5..6f711dad0 100644 --- a/telepathy-glib/presence-mixin.c +++ b/telepathy-glib/presence-mixin.c @@ -274,6 +274,7 @@ #include <telepathy-glib/errors.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/svc-connection.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c index a07423ba2..3e815b526 100644 --- a/telepathy-glib/protocol.c +++ b/telepathy-glib/protocol.c @@ -42,6 +42,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/telepathy-glib.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/room-info.c b/telepathy-glib/room-info.c index df0dee2a1..162e47ddf 100644 --- a/telepathy-glib/room-info.c +++ b/telepathy-glib/room-info.c @@ -25,6 +25,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/dbus.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/value-array.h> diff --git a/telepathy-glib/signalled-message.c b/telepathy-glib/signalled-message.c index 55ac10779..c6baac429 100644 --- a/telepathy-glib/signalled-message.c +++ b/telepathy-glib/signalled-message.c @@ -40,6 +40,7 @@ #include <telepathy-glib/dbus.h> #include <telepathy-glib/gtypes.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> /** diff --git a/telepathy-glib/sliced-gvalue.c b/telepathy-glib/sliced-gvalue.c new file mode 100644 index 000000000..5908d45d0 --- /dev/null +++ b/telepathy-glib/sliced-gvalue.c @@ -0,0 +1,497 @@ +/* + * sliced-gvalue.c - slice-allocated GValues + * + * Copyright (C) 2005-2010 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright (C) 2005-2009 Nokia Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * SECTION:sliced-gvalue + * @title: slice-allocated GValues + * @short_description: GValue utility functions + * + * These functions are a convenient way to slice-allocate GValues + * with various contents, as used in dbus-glib. + */ + +#include "config.h" + +#include <telepathy-glib/sliced-gvalue.h> + +#include <dbus/dbus-glib.h> + +/** + * tp_g_value_slice_new: (skip) + * @type: The type desired for the new GValue + * + * Slice-allocate an empty #GValue. tp_g_value_slice_new_boolean() and similar + * functions are likely to be more convenient to use for the types supported. + * + * Returns: a newly allocated, newly initialized #GValue, to be freed with + * tp_g_value_slice_free() or g_slice_free(). + * Since: 0.5.14 + */ +GValue * +tp_g_value_slice_new (GType type) +{ + GValue *ret = g_slice_new0 (GValue); + + g_value_init (ret, type); + return ret; +} + +/** + * tp_g_value_slice_new_boolean: (skip) + * @b: a boolean value + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_BOOLEAN with value @b, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_boolean (gboolean b) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_BOOLEAN); + + g_value_set_boolean (v, b); + return v; +} + +/** + * tp_g_value_slice_new_int: (skip) + * @n: an integer + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_INT with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_int (gint n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_INT); + + g_value_set_int (v, n); + return v; +} + +/** + * tp_g_value_slice_new_int64: (skip) + * @n: a 64-bit integer + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_INT64 with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_int64 (gint64 n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_INT64); + + g_value_set_int64 (v, n); + return v; +} + +/** + * tp_g_value_slice_new_byte: (skip) + * @n: an unsigned integer + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_UCHAR with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.11.0 + */ +GValue * +tp_g_value_slice_new_byte (guchar n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_UCHAR); + + g_value_set_uchar (v, n); + return v; +} + +/** + * tp_g_value_slice_new_uint: (skip) + * @n: an unsigned integer + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_UINT with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_uint (guint n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_UINT); + + g_value_set_uint (v, n); + return v; +} + +/** + * tp_g_value_slice_new_uint64: (skip) + * @n: a 64-bit unsigned integer + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_UINT64 with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_uint64 (guint64 n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_UINT64); + + g_value_set_uint64 (v, n); + return v; +} + +/** + * tp_g_value_slice_new_double: (skip) + * @d: a number + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_DOUBLE with value @n, to be freed with + * tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_double (double n) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_DOUBLE); + + g_value_set_double (v, n); + return v; +} + +/** + * tp_g_value_slice_new_string: (skip) + * @string: a string to be copied into the value + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_STRING whose value is a copy of @string, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_string (const gchar *string) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_STRING); + + g_value_set_string (v, string); + return v; +} + +/** + * tp_g_value_slice_new_static_string: (skip) + * @string: a static string which must remain valid forever, to be pointed to + * by the value + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_STRING whose value is @string, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_static_string (const gchar *string) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_STRING); + + g_value_set_static_string (v, string); + return v; +} + +/** + * tp_g_value_slice_new_take_string: (skip) + * @string: a string which will be freed with g_free() by the returned #GValue + * (the caller must own it before calling this function, but no longer owns + * it after this function returns) + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %G_TYPE_STRING whose value is @string, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_take_string (gchar *string) +{ + GValue *v = tp_g_value_slice_new (G_TYPE_STRING); + + g_value_take_string (v, string); + return v; +} + +/** + * tp_g_value_slice_new_boxed: (skip) + * @type: a boxed type + * @p: a pointer of type @type, which will be copied + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type @type whose value is a copy of @p, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_boxed (GType type, + gconstpointer p) +{ + GValue *v; + + g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); + v = tp_g_value_slice_new (type); + g_value_set_boxed (v, p); + return v; +} + +/** + * tp_g_value_slice_new_static_boxed: (skip) + * @type: a boxed type + * @p: a pointer of type @type, which must remain valid forever + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type @type whose value is @p, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_static_boxed (GType type, + gconstpointer p) +{ + GValue *v; + + g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); + v = tp_g_value_slice_new (type); + g_value_set_static_boxed (v, p); + return v; +} + +/** + * tp_g_value_slice_new_take_boxed: (skip) + * @type: a boxed type + * @p: a pointer of type @type which will be freed with g_boxed_free() by the + * returned #GValue (the caller must own it before calling this function, but + * no longer owns it after this function returns) + * + * Slice-allocate and initialize a #GValue. This function is convenient to + * use when constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type @type whose value is @p, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_take_boxed (GType type, + gpointer p) +{ + GValue *v; + + g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); + v = tp_g_value_slice_new (type); + g_value_take_boxed (v, p); + return v; +} + +/** + * tp_g_value_slice_free: (skip) + * @value: A GValue which was allocated with the g_slice API + * + * Unset and free a slice-allocated GValue. + * + * <literal>(GDestroyNotify) tp_g_value_slice_free</literal> can be used + * as a destructor for values in a #GHashTable, for example. + */ + +void +tp_g_value_slice_free (GValue *value) +{ + g_value_unset (value); + g_slice_free (GValue, value); +} + + +/** + * tp_g_value_slice_dup: (skip) + * @value: A GValue + * + * <!-- 'Returns' says it all --> + * + * Returns: a newly allocated copy of @value, to be freed with + * tp_g_value_slice_free() or g_slice_free(). + * Since: 0.5.14 + */ +GValue * +tp_g_value_slice_dup (const GValue *value) +{ + GValue *ret = tp_g_value_slice_new (G_VALUE_TYPE (value)); + + g_value_copy (value, ret); + return ret; +} + +/** + * tp_g_value_slice_new_bytes: (skip) + * @length: number of bytes to copy + * @bytes: location of an array of bytes to be copied (this may be %NULL + * if and only if length is 0) + * + * Slice-allocate a #GValue containing a byte-array, using + * tp_g_value_slice_new_boxed(). This function is convenient to use when + * constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %DBUS_TYPE_G_UCHAR_ARRAY whose value is a copy + * of @length bytes from @bytes, to be freed with tp_g_value_slice_free() or + * g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_bytes (guint length, + gconstpointer bytes) +{ + GArray *arr; + + g_return_val_if_fail (length == 0 || bytes != NULL, NULL); + arr = g_array_sized_new (FALSE, FALSE, 1, length); + + if (length > 0) + g_array_append_vals (arr, bytes, length); + + return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_UCHAR_ARRAY, arr); +} + +/** + * tp_g_value_slice_new_take_bytes: (skip) + * @bytes: a non-NULL #GArray of guchar, ownership of which will be taken by + * the #GValue + * + * Slice-allocate a #GValue containing @bytes, using + * tp_g_value_slice_new_boxed(). This function is convenient to use when + * constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %DBUS_TYPE_G_UCHAR_ARRAY whose value is + * @bytes, to be freed with tp_g_value_slice_free() or + * g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_take_bytes (GArray *bytes) +{ + g_return_val_if_fail (bytes != NULL, NULL); + return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_UCHAR_ARRAY, bytes); +} + +/** + * tp_g_value_slice_new_object_path: (skip) + * @path: a valid D-Bus object path which will be copied + * + * Slice-allocate a #GValue containing an object path, using + * tp_g_value_slice_new_boxed(). This function is convenient to use when + * constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is a copy + * of @path, to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_object_path (const gchar *path) +{ + g_return_val_if_fail (g_variant_is_object_path (path), NULL); + return tp_g_value_slice_new_boxed (DBUS_TYPE_G_OBJECT_PATH, path); +} + +/** + * tp_g_value_slice_new_static_object_path: (skip) + * @path: a valid D-Bus object path which must remain valid forever + * + * Slice-allocate a #GValue containing an object path, using + * tp_g_value_slice_new_static_boxed(). This function is convenient to use when + * constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is @path, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_static_object_path (const gchar *path) +{ + g_return_val_if_fail (g_variant_is_object_path (path), NULL); + return tp_g_value_slice_new_static_boxed (DBUS_TYPE_G_OBJECT_PATH, path); +} + +/** + * tp_g_value_slice_new_take_object_path: (skip) + * @path: a valid D-Bus object path which will be freed with g_free() by the + * returned #GValue (the caller must own it before calling this function, but + * no longer owns it after this function returns) + * + * Slice-allocate a #GValue containing an object path, using + * tp_g_value_slice_new_take_boxed(). This function is convenient to use when + * constructing hash tables from string to #GValue, for example. + * + * Returns: a #GValue of type %DBUS_TYPE_G_OBJECT_PATH whose value is @path, + * to be freed with tp_g_value_slice_free() or g_slice_free() + * + * Since: 0.7.27 + */ +GValue * +tp_g_value_slice_new_take_object_path (gchar *path) +{ + g_return_val_if_fail (g_variant_is_object_path (path), NULL); + return tp_g_value_slice_new_take_boxed (DBUS_TYPE_G_OBJECT_PATH, path); +} diff --git a/telepathy-glib/sliced-gvalue.h b/telepathy-glib/sliced-gvalue.h new file mode 100644 index 000000000..4f46479ca --- /dev/null +++ b/telepathy-glib/sliced-gvalue.h @@ -0,0 +1,79 @@ +/* + * sliced-gvalue.h - slice-allocated GValues + * + * Copyright © 2005-2010 Collabora Ltd. <http://www.collabora.co.uk/> + * Copyright © 2005-2009 Nokia Corporation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if !defined (_TP_GLIB_DBUS_H_INSIDE) && !defined (_TP_COMPILATION) +#error "Only <telepathy-glib/telepathy-glib-dbus.h> can be included directly." +#endif + +#ifndef __TP_SLICED_GVALUE_H__ +#define __TP_SLICED_GVALUE_H__ + +#include <telepathy-glib/telepathy-glib.h> + +G_BEGIN_DECLS + +/* Functions with _new in their names confuse the g-i scanner, but these + * are all (skip)'d anyway. See GNOME bug#656743 */ +#ifndef __GI_SCANNER__ +GValue *tp_g_value_slice_new_bytes (guint length, gconstpointer bytes) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_take_bytes (GArray *bytes) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_object_path (const gchar *path) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_static_object_path (const gchar *path) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_take_object_path (gchar *path) + G_GNUC_WARN_UNUSED_RESULT; + +GValue *tp_g_value_slice_new (GType type) G_GNUC_WARN_UNUSED_RESULT; + +GValue *tp_g_value_slice_new_boolean (gboolean b) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_int (gint n) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_int64 (gint64 n) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_byte (guchar n) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_uint (guint n) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_uint64 (guint64 n) G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_double (double d) G_GNUC_WARN_UNUSED_RESULT; + +GValue *tp_g_value_slice_new_string (const gchar *string) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_static_string (const gchar *string) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_take_string (gchar *string) + G_GNUC_WARN_UNUSED_RESULT; + +GValue *tp_g_value_slice_new_boxed (GType type, gconstpointer p) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_static_boxed (GType type, gconstpointer p) + G_GNUC_WARN_UNUSED_RESULT; +GValue *tp_g_value_slice_new_take_boxed (GType type, gpointer p) + G_GNUC_WARN_UNUSED_RESULT; + +#endif + +void tp_g_value_slice_free (GValue *value); + +GValue *tp_g_value_slice_dup (const GValue *value) G_GNUC_WARN_UNUSED_RESULT; + +G_END_DECLS + +#endif /* single-inclusion guard */ diff --git a/telepathy-glib/stream-tube-channel.c b/telepathy-glib/stream-tube-channel.c index 01f86eb99..a785c75bf 100644 --- a/telepathy-glib/stream-tube-channel.c +++ b/telepathy-glib/stream-tube-channel.c @@ -59,6 +59,7 @@ #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/stream-tube-connection-internal.h> #include <telepathy-glib/util-internal.h> #include <telepathy-glib/util.h> diff --git a/telepathy-glib/telepathy-glib-dbus.h b/telepathy-glib/telepathy-glib-dbus.h index 9e533b780..618c1cc9d 100644 --- a/telepathy-glib/telepathy-glib-dbus.h +++ b/telepathy-glib/telepathy-glib-dbus.h @@ -26,6 +26,7 @@ #define _TP_GLIB_DBUS_H_INSIDE /* utilities for the dbus-glib type system */ +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/value-array.h> /* common */ diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c index 1f44576de..3fd63d4f6 100644 --- a/telepathy-glib/util.c +++ b/telepathy-glib/util.c @@ -111,353 +111,6 @@ tp_g_ptr_array_extend (GPtrArray *target, g_ptr_array_foreach (source, add_to_array, target); } -/** - * tp_g_value_slice_new: (skip) - * @type: The type desired for the new GValue - * - * Slice-allocate an empty #GValue. tp_g_value_slice_new_boolean() and similar - * functions are likely to be more convenient to use for the types supported. - * - * Returns: a newly allocated, newly initialized #GValue, to be freed with - * tp_g_value_slice_free() or g_slice_free(). - * Since: 0.5.14 - */ -GValue * -tp_g_value_slice_new (GType type) -{ - GValue *ret = g_slice_new0 (GValue); - - g_value_init (ret, type); - return ret; -} - -/** - * tp_g_value_slice_new_boolean: (skip) - * @b: a boolean value - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_BOOLEAN with value @b, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_boolean (gboolean b) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_BOOLEAN); - - g_value_set_boolean (v, b); - return v; -} - -/** - * tp_g_value_slice_new_int: (skip) - * @n: an integer - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_INT with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_int (gint n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_INT); - - g_value_set_int (v, n); - return v; -} - -/** - * tp_g_value_slice_new_int64: (skip) - * @n: a 64-bit integer - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_INT64 with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_int64 (gint64 n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_INT64); - - g_value_set_int64 (v, n); - return v; -} - -/** - * tp_g_value_slice_new_byte: (skip) - * @n: an unsigned integer - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_UCHAR with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.11.0 - */ -GValue * -tp_g_value_slice_new_byte (guchar n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_UCHAR); - - g_value_set_uchar (v, n); - return v; -} - -/** - * tp_g_value_slice_new_uint: (skip) - * @n: an unsigned integer - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_UINT with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_uint (guint n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_UINT); - - g_value_set_uint (v, n); - return v; -} - -/** - * tp_g_value_slice_new_uint64: (skip) - * @n: a 64-bit unsigned integer - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_UINT64 with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_uint64 (guint64 n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_UINT64); - - g_value_set_uint64 (v, n); - return v; -} - -/** - * tp_g_value_slice_new_double: (skip) - * @d: a number - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_DOUBLE with value @n, to be freed with - * tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_double (double n) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_DOUBLE); - - g_value_set_double (v, n); - return v; -} - -/** - * tp_g_value_slice_new_string: (skip) - * @string: a string to be copied into the value - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_STRING whose value is a copy of @string, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_string (const gchar *string) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_STRING); - - g_value_set_string (v, string); - return v; -} - -/** - * tp_g_value_slice_new_static_string: (skip) - * @string: a static string which must remain valid forever, to be pointed to - * by the value - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_STRING whose value is @string, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_static_string (const gchar *string) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_STRING); - - g_value_set_static_string (v, string); - return v; -} - -/** - * tp_g_value_slice_new_take_string: (skip) - * @string: a string which will be freed with g_free() by the returned #GValue - * (the caller must own it before calling this function, but no longer owns - * it after this function returns) - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type %G_TYPE_STRING whose value is @string, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_take_string (gchar *string) -{ - GValue *v = tp_g_value_slice_new (G_TYPE_STRING); - - g_value_take_string (v, string); - return v; -} - -/** - * tp_g_value_slice_new_boxed: (skip) - * @type: a boxed type - * @p: a pointer of type @type, which will be copied - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type @type whose value is a copy of @p, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_boxed (GType type, - gconstpointer p) -{ - GValue *v; - - g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); - v = tp_g_value_slice_new (type); - g_value_set_boxed (v, p); - return v; -} - -/** - * tp_g_value_slice_new_static_boxed: (skip) - * @type: a boxed type - * @p: a pointer of type @type, which must remain valid forever - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type @type whose value is @p, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_static_boxed (GType type, - gconstpointer p) -{ - GValue *v; - - g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); - v = tp_g_value_slice_new (type); - g_value_set_static_boxed (v, p); - return v; -} - -/** - * tp_g_value_slice_new_take_boxed: (skip) - * @type: a boxed type - * @p: a pointer of type @type which will be freed with g_boxed_free() by the - * returned #GValue (the caller must own it before calling this function, but - * no longer owns it after this function returns) - * - * Slice-allocate and initialize a #GValue. This function is convenient to - * use when constructing hash tables from string to #GValue, for example. - * - * Returns: a #GValue of type @type whose value is @p, - * to be freed with tp_g_value_slice_free() or g_slice_free() - * - * Since: 0.7.27 - */ -GValue * -tp_g_value_slice_new_take_boxed (GType type, - gpointer p) -{ - GValue *v; - - g_return_val_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED, NULL); - v = tp_g_value_slice_new (type); - g_value_take_boxed (v, p); - return v; -} - -/** - * tp_g_value_slice_free: (skip) - * @value: A GValue which was allocated with the g_slice API - * - * Unset and free a slice-allocated GValue. - * - * <literal>(GDestroyNotify) tp_g_value_slice_free</literal> can be used - * as a destructor for values in a #GHashTable, for example. - */ - -void -tp_g_value_slice_free (GValue *value) -{ - g_value_unset (value); - g_slice_free (GValue, value); -} - - -/** - * tp_g_value_slice_dup: (skip) - * @value: A GValue - * - * <!-- 'Returns' says it all --> - * - * Returns: a newly allocated copy of @value, to be freed with - * tp_g_value_slice_free() or g_slice_free(). - * Since: 0.5.14 - */ -GValue * -tp_g_value_slice_dup (const GValue *value) -{ - GValue *ret = tp_g_value_slice_new (G_VALUE_TYPE (value)); - - g_value_copy (value, ret); - return ret; -} - struct _tp_g_hash_table_update { diff --git a/telepathy-glib/util.h b/telepathy-glib/util.h index 02a392d73..58c8a8d05 100644 --- a/telepathy-glib/util.h +++ b/telepathy-glib/util.h @@ -36,40 +36,6 @@ G_BEGIN_DECLS gboolean tp_g_ptr_array_contains (GPtrArray *haystack, gpointer needle); void tp_g_ptr_array_extend (GPtrArray *target, GPtrArray *source); -#ifndef __GI_SCANNER__ -/* Functions with _new in their names confuse the g-i scanner, but these - * are all (skip)'d anyway. */ - -GValue *tp_g_value_slice_new (GType type) G_GNUC_WARN_UNUSED_RESULT; - -GValue *tp_g_value_slice_new_boolean (gboolean b) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_int (gint n) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_int64 (gint64 n) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_byte (guchar n) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_uint (guint n) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_uint64 (guint64 n) G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_double (double d) G_GNUC_WARN_UNUSED_RESULT; - -GValue *tp_g_value_slice_new_string (const gchar *string) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_static_string (const gchar *string) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_take_string (gchar *string) - G_GNUC_WARN_UNUSED_RESULT; - -GValue *tp_g_value_slice_new_boxed (GType type, gconstpointer p) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_static_boxed (GType type, gconstpointer p) - G_GNUC_WARN_UNUSED_RESULT; -GValue *tp_g_value_slice_new_take_boxed (GType type, gpointer p) - G_GNUC_WARN_UNUSED_RESULT; - -#endif - -void tp_g_value_slice_free (GValue *value); - -GValue *tp_g_value_slice_dup (const GValue *value) G_GNUC_WARN_UNUSED_RESULT; - void tp_g_hash_table_update (GHashTable *target, GHashTable *source, GBoxedCopyFunc key_dup, GBoxedCopyFunc value_dup); diff --git a/telepathy-glib/versions/dbus-1.0.abi b/telepathy-glib/versions/dbus-1.0.abi index d53a2d127..3f392bbd7 100644 --- a/telepathy-glib/versions/dbus-1.0.abi +++ b/telepathy-glib/versions/dbus-1.0.abi @@ -259,6 +259,27 @@ tp_cli_protocol_call_normalize_contact tp_cli_protocol_interface_addressing1_call_normalize_contact_uri tp_cli_protocol_interface_addressing1_call_normalize_vcard_address tp_dbus_specialized_value_slice_new +tp_g_value_slice_dup +tp_g_value_slice_free +tp_g_value_slice_new +tp_g_value_slice_new_boolean +tp_g_value_slice_new_boxed +tp_g_value_slice_new_byte +tp_g_value_slice_new_bytes +tp_g_value_slice_new_double +tp_g_value_slice_new_int +tp_g_value_slice_new_int64 +tp_g_value_slice_new_object_path +tp_g_value_slice_new_static_boxed +tp_g_value_slice_new_static_object_path +tp_g_value_slice_new_static_string +tp_g_value_slice_new_string +tp_g_value_slice_new_take_boxed +tp_g_value_slice_new_take_bytes +tp_g_value_slice_new_take_object_path +tp_g_value_slice_new_take_string +tp_g_value_slice_new_uint +tp_g_value_slice_new_uint64 tp_iface_quark_account tp_iface_quark_account_interface_addressing1 tp_iface_quark_account_interface_avatar1 diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi index 349e5fc25..8a9c2055a 100644 --- a/telepathy-glib/versions/main-1.0.abi +++ b/telepathy-glib/versions/main-1.0.abi @@ -876,27 +876,6 @@ tp_g_ptr_array_extend tp_g_signal_connect_object tp_g_socket_address_from_g_variant tp_g_socket_address_from_variant -tp_g_value_slice_dup -tp_g_value_slice_free -tp_g_value_slice_new -tp_g_value_slice_new_boolean -tp_g_value_slice_new_boxed -tp_g_value_slice_new_byte -tp_g_value_slice_new_bytes -tp_g_value_slice_new_double -tp_g_value_slice_new_int -tp_g_value_slice_new_int64 -tp_g_value_slice_new_object_path -tp_g_value_slice_new_static_boxed -tp_g_value_slice_new_static_object_path -tp_g_value_slice_new_static_string -tp_g_value_slice_new_string -tp_g_value_slice_new_take_boxed -tp_g_value_slice_new_take_bytes -tp_g_value_slice_new_take_object_path -tp_g_value_slice_new_take_string -tp_g_value_slice_new_uint -tp_g_value_slice_new_uint64 tp_group_mixin_add_handle_owner tp_group_mixin_add_handle_owners tp_group_mixin_add_members diff --git a/tests/dbus/call-channel.c b/tests/dbus/call-channel.c index b06b6e2d5..2e2506728 100644 --- a/tests/dbus/call-channel.c +++ b/tests/dbus/call-channel.c @@ -28,6 +28,7 @@ #include <telepathy-glib/proxy-subclass.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include "telepathy-glib/reentrants.h" diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c index 6ecc4b978..e21913884 100644 --- a/tests/dbus/cli-group.c +++ b/tests/dbus/cli-group.c @@ -21,6 +21,7 @@ #include <telepathy-glib/interfaces.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include "telepathy-glib/reentrants.h" diff --git a/tests/dbus/group-mixin.c b/tests/dbus/group-mixin.c index 952e453aa..e6bad03d0 100644 --- a/tests/dbus/group-mixin.c +++ b/tests/dbus/group-mixin.c @@ -21,6 +21,7 @@ #include <telepathy-glib/interfaces.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/proxy-subclass.h> +#include <telepathy-glib/sliced-gvalue.h> #include "telepathy-glib/reentrants.h" diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c index c7e04d87b..e09e5d76f 100644 --- a/tests/dbus/message-mixin.c +++ b/tests/dbus/message-mixin.c @@ -21,6 +21,7 @@ #include <telepathy-glib/debug.h> #include <telepathy-glib/gtypes.h> #include <telepathy-glib/interfaces.h> +#include <telepathy-glib/sliced-gvalue.h> #include "telepathy-glib/reentrants.h" diff --git a/tests/gnio-util.c b/tests/gnio-util.c index 107d96cc0..a210e109f 100644 --- a/tests/gnio-util.c +++ b/tests/gnio-util.c @@ -13,6 +13,7 @@ #endif /* HAVE_GIO_UNIX */ #include <telepathy-glib/gnio-util.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> #include <telepathy-glib/gtypes.h> diff --git a/tests/intset.c b/tests/intset.c index 662ee4bac..5f9e69ab3 100644 --- a/tests/intset.c +++ b/tests/intset.c @@ -2,6 +2,7 @@ #include <glib.h> #include <telepathy-glib/intset.h> +#include <telepathy-glib/sliced-gvalue.h> #include <telepathy-glib/util.h> typedef struct { |