[telepathy-glib/master] take_ and set_static_ functions, fix up const markers on some other functions

Davyd Madeley davyd at madeley.id.au
Thu Apr 2 20:08:17 PDT 2009


tp_asv_take_boxed(), tp_asv_set_static_boxed(), tp_asv_take_bytes(),
tp_asv_take_object_path(), tp_asv_set_static_object_path(),
tp_asv_take_string()
---
 docs/reference/telepathy-glib-sections.txt |    6 +
 telepathy-glib/dbus.c                      |  194 ++++++++++++++++++++++++++--
 telepathy-glib/dbus.h                      |   21 +++-
 3 files changed, 204 insertions(+), 17 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 0ef73e6..122bfa2 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1440,8 +1440,11 @@ tp_asv_get_boolean
 tp_asv_set_boolean
 tp_asv_get_boxed
 tp_asv_set_boxed
+tp_asv_take_boxed
+tp_asv_set_static_boxed
 tp_asv_get_bytes
 tp_asv_set_bytes
+tp_asv_take_bytes
 tp_asv_get_double
 tp_asv_set_double
 tp_asv_get_int32
@@ -1450,8 +1453,11 @@ tp_asv_get_int64
 tp_asv_set_int64
 tp_asv_get_object_path
 tp_asv_set_object_path
+tp_asv_take_object_path
+tp_asv_set_static_object_path
 tp_asv_get_string
 tp_asv_set_string
+tp_asv_take_string
 tp_asv_set_static_string
 tp_asv_get_strv
 tp_asv_set_strv
diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c
index 1d59f85..a4db581 100644
--- a/telepathy-glib/dbus.c
+++ b/telepathy-glib/dbus.c
@@ -1530,25 +1530,56 @@ tp_asv_get_bytes (const GHashTable *asv,
  * tp_asv_set_bytes:
  * @asv: a #GHashTable created with tp_asv_new()
  * @key: string key
- * @value: value
+ * @length: the 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)
  *
  * Stores the value in the map.
  *
  * The value is stored as a slice-allocated GValue.
  *
- * See Also: tp_asv_new(), tp_asv_get_bytes()
+ * See Also: tp_asv_new(), tp_asv_get_bytes(), tp_g_value_slice_new_bytes()
  * Since: UNRELEASED
  */
 void
 tp_asv_set_bytes (GHashTable *asv,
                   const gchar *key,
-                  GArray *value)
+                  guint length,
+                  gconstpointer bytes)
 {
   g_return_if_fail (asv != NULL);
   g_return_if_fail (key != NULL);
+  g_return_if_fail (!(length > 0 && bytes == NULL));
 
   g_hash_table_insert (asv, (char *) key,
-      tp_g_value_slice_new_boxed (DBUS_TYPE_G_UCHAR_ARRAY, value));
+      tp_g_value_slice_new_bytes (length, bytes));
+}
+
+/**
+ * tp_asv_take_bytes:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @value: a non-NULL #GArray of %guchar, ownership of which will be taken by
+ * the #GValue
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_bytes(), tp_g_value_slice_new_take_bytes()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_take_bytes (GHashTable *asv,
+                   const gchar *key,
+                   GArray *value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (value != NULL);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_take_bytes (value));
 }
 
 /**
@@ -1594,13 +1625,13 @@ tp_asv_get_string (const GHashTable *asv,
  *
  * The value is stored as a slice-allocated GValue.
  *
- * See Also: tp_asv_new(), tp_asv_get_string(), tp_asv_set_static_string()
+ * See Also: tp_asv_new(), tp_asv_get_string(), tp_g_value_slice_new_string()
  * Since: UNRELEASED
  */
 void
 tp_asv_set_string (GHashTable *asv,
                    const gchar *key,
-                   gchar *value)
+                   const gchar *value)
 {
   g_return_if_fail (asv != NULL);
   g_return_if_fail (key != NULL);
@@ -1609,6 +1640,32 @@ tp_asv_set_string (GHashTable *asv,
 }
 
 /**
+ * tp_asv_take_string:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @value: value
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_string(),
+ * tp_g_value_slice_new_take_string()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_take_string (GHashTable *asv,
+                    const gchar *key,
+                    gchar *value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_take_string (value));
+}
+
+/**
  * tp_asv_set_static_string:
  * @asv: a #GHashTable created with tp_asv_new()
  * @key: string key
@@ -1618,13 +1675,14 @@ tp_asv_set_string (GHashTable *asv,
  *
  * The value is stored as a slice-allocated GValue.
  *
- * See Also: tp_asv_new(), tp_asv_get_string(), tp_asv_set_string()
+ * See Also: tp_asv_new(), tp_asv_get_string(),
+ * tp_g_value_slice_new_static_string()
  * Since: UNRELEASED
  */
 void
 tp_asv_set_static_string (GHashTable *asv,
                           const gchar *key,
-                          gchar *value)
+                          const gchar *value)
 {
   g_return_if_fail (asv != NULL);
   g_return_if_fail (key != NULL);
@@ -2204,19 +2262,72 @@ tp_asv_get_object_path (const GHashTable *asv,
  *
  * The value is stored as a slice-allocated GValue.
  *
- * See Also: tp_asv_new(), tp_asv_get_object_path()
+ * See Also: tp_asv_new(), tp_asv_get_object_path(),
+ * tp_g_value_slice_new_object_path()
  * Since: UNRELEASED
  */
 void
 tp_asv_set_object_path (GHashTable *asv,
                         const gchar *key,
-                        gchar *value)
+                        const gchar *value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_object_path (value));
+}
+
+/**
+ * tp_asv_take_object_path:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @value: value
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_object_path(),
+ * tp_g_value_slice_new_take_object_path()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_take_object_path (GHashTable *asv,
+                         const gchar *key,
+                         gchar *value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_take_object_path (value));
+}
+
+/**
+ * tp_asv_set_static_object_path:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @value: value
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_object_path(),
+ * tp_g_value_slice_new_static_object_path()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_set_static_object_path (GHashTable *asv,
+                               const gchar *key,
+                               const gchar *value)
 {
   g_return_if_fail (asv != NULL);
   g_return_if_fail (key != NULL);
 
   g_hash_table_insert (asv, (char *) key,
-      tp_g_value_slice_new_boxed (DBUS_TYPE_G_OBJECT_PATH, value));
+      tp_g_value_slice_new_static_object_path (value));
 }
 
 /**
@@ -2268,14 +2379,14 @@ tp_asv_get_boxed (const GHashTable *asv,
  *
  * The value is stored as a slice-allocated GValue.
  *
- * See Also: tp_asv_new(), tp_asv_get_boxed()
+ * See Also: tp_asv_new(), tp_asv_get_boxed(), tp_g_value_slice_new_boxed()
  * Since: UNRELEASED
  */
 void
 tp_asv_set_boxed (GHashTable *asv,
                   const gchar *key,
                   GType type,
-                  gpointer value)
+                  gconstpointer value)
 {
   g_return_if_fail (asv != NULL);
   g_return_if_fail (key != NULL);
@@ -2286,6 +2397,63 @@ tp_asv_set_boxed (GHashTable *asv,
 }
 
 /**
+ * tp_asv_take_boxed:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @type: the type of the key's value, which must be derived from %G_TYPE_BOXED
+ * @value: value
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_boxed(), tp_g_value_slice_new_take_boxed()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_take_boxed (GHashTable *asv,
+                   const gchar *key,
+                   GType type,
+                   gpointer value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_take_boxed (type, value));
+}
+
+/**
+ * tp_asv_set_static_boxed:
+ * @asv: a #GHashTable created with tp_asv_new()
+ * @key: string key
+ * @type: the type of the key's value, which must be derived from %G_TYPE_BOXED
+ * @value: value
+ *
+ * Stores the value in the map.
+ *
+ * The value is stored as a slice-allocated GValue.
+ *
+ * See Also: tp_asv_new(), tp_asv_get_boxed(),
+ * tp_g_value_slice_new_static_boxed()
+ * Since: UNRELEASED
+ */
+void
+tp_asv_set_static_boxed (GHashTable *asv,
+                         const gchar *key,
+                         GType type,
+                         gconstpointer value)
+{
+  g_return_if_fail (asv != NULL);
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED);
+
+  g_hash_table_insert (asv, (char *) key,
+      tp_g_value_slice_new_static_boxed (type, value));
+}
+
+/**
  * tp_asv_get_strv:
  * @asv: A GHashTable where the keys are strings and the values are GValues
  * @key: The key to look up
diff --git a/telepathy-glib/dbus.h b/telepathy-glib/dbus.h
index 0c31964..949b48a 100644
--- a/telepathy-glib/dbus.h
+++ b/telepathy-glib/dbus.h
@@ -111,9 +111,15 @@ void tp_asv_set_boolean (GHashTable *asv, const gchar *key, gboolean value);
 gpointer tp_asv_get_boxed (const GHashTable *asv, const gchar *key,
     GType type);
 void tp_asv_set_boxed (GHashTable *asv, const gchar *key, GType type,
+    gconstpointer value);
+void tp_asv_take_boxed (GHashTable *asv, const gchar *key, GType type,
     gpointer value);
+void tp_asv_set_static_boxed (GHashTable *asv, const gchar *key, GType type,
+    gconstpointer value);
 const GArray *tp_asv_get_bytes (const GHashTable *asv, const gchar *key);
-void tp_asv_set_bytes (GHashTable *asv, const gchar *key, GArray *value);
+void tp_asv_set_bytes (GHashTable *asv, const gchar *key, guint length,
+    gconstpointer bytes);
+void tp_asv_take_bytes (GHashTable *asv, const gchar *key, GArray *value);
 gdouble tp_asv_get_double (const GHashTable *asv, const gchar *key,
     gboolean *valid);
 void tp_asv_set_double (GHashTable *asv, const gchar *key, gdouble value);
@@ -124,10 +130,17 @@ gint64 tp_asv_get_int64 (const GHashTable *asv, const gchar *key,
     gboolean *valid);
 void tp_asv_set_int64 (GHashTable *asv, const gchar *key, gint64 value);
 const gchar *tp_asv_get_object_path (const GHashTable *asv, const gchar *key);
-void tp_asv_set_object_path (GHashTable *asv, const gchar *key, gchar *value);
+void tp_asv_set_object_path (GHashTable *asv, const gchar *key,
+    const gchar *value);
+void tp_asv_take_object_path (GHashTable *asv, const gchar *key,
+    gchar *value);
+void tp_asv_set_static_object_path (GHashTable *asv, const gchar *key,
+    const gchar *value);
 const gchar *tp_asv_get_string (const GHashTable *asv, const gchar *key);
-void tp_asv_set_string (GHashTable *asv, const gchar *key, gchar *value);
-void tp_asv_set_static_string (GHashTable *asv, const gchar *key, gchar *value);
+void tp_asv_set_string (GHashTable *asv, const gchar *key, const gchar *value);
+void tp_asv_take_string (GHashTable *asv, const gchar *key, gchar *value);
+void tp_asv_set_static_string (GHashTable *asv, const gchar *key,
+    const gchar *value);
 guint32 tp_asv_get_uint32 (const GHashTable *asv, const gchar *key,
     gboolean *valid);
 void tp_asv_set_uint32 (GHashTable *asv, const gchar *key, guint32 value);
-- 
1.5.6.5




More information about the telepathy-commits mailing list