[glib/wip/gproperty: 1115/1118] gproperty: Remove collection API



commit 3c6ffb5c31d18adda5b8bed1e602a8b8b9460dcf
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Aug 17 14:31:26 2011 +0100

    gproperty: Remove collection API
    
    We can augment g_property_set_valist() and g_property_get_valist() with
    the collection flags and use a pointer to a va_list instead of a simple
    va_list - similarly to what GVariant does in g_variant_new_va().

 gobject/gobject.c         |   14 +-
 gobject/gobject.symbols   |    2 -
 gobject/gproperty.c       |  550 +++++++--------------------------------------
 gobject/gproperty.h       |   44 +++--
 gobject/gvaluecollector.h |  118 ----------
 5 files changed, 106 insertions(+), 622 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index d424f59..accf7d5 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -2080,11 +2080,8 @@ g_object_set_valist (GObject	 *object,
       if (G_IS_PROPERTY (pspec))
         {
           GProperty *property = (GProperty *) pspec;
-          gboolean res = FALSE;
 
-          G_PROPERTY_COLLECT (property, object, 0, var_args, &res);
-          if (!res)
-            break;
+          g_property_set_valist (property, object, 0, &var_args);
         }
       else
         {
@@ -2167,17 +2164,14 @@ g_object_get_valist (GObject	 *object,
       if (G_IS_PROPERTY (pspec))
         {
           GProperty *property = (GProperty *) pspec;
-          gboolean res = FALSE;
+          GPropertyFlags flags = G_PROPERTY_COLLECT_REF
+                               | G_PROPERTY_COLLECT_COPY;
 
           /* we use G_PROPERTY_COLLECT_COPY and G_PROPERTY_COLLECT_REF to
            * preserve the semantics of GValues holding a typed pointer
            * value, like GObject, GBoxed and strings
            */
-          G_PROPERTY_LCOPY (property, object,
-                            G_PROPERTY_COLLECT_REF | G_PROPERTY_COLLECT_COPY,
-                            var_args,
-                            &res);
-          if (!res)
+          if (!g_property_get_valist (property, object, flags, &var_args))
             break;
         }
       else
diff --git a/gobject/gobject.symbols b/gobject/gobject.symbols
index be9b768..8defe3a 100644
--- a/gobject/gobject.symbols
+++ b/gobject/gobject.symbols
@@ -254,7 +254,6 @@ g_long_property_new
 g_object_property_new
 g_pointer_property_new
 g_property_canonicalize_name
-g_property_collect
 g_property_describe
 g_property_get
 g_property_get_default
@@ -270,7 +269,6 @@ g_property_is_atomic
 g_property_is_deprecated
 g_property_is_readable
 g_property_is_writable
-g_property_lcopy
 g_property_lock
 g_property_set
 g_property_set_default
diff --git a/gobject/gproperty.c b/gobject/gproperty.c
index 0c8b072..b94b62b 100644
--- a/gobject/gproperty.c
+++ b/gobject/gproperty.c
@@ -400,16 +400,6 @@
  *     </itemizedlist>
  *   </refsect3>
  *
- *   <refsect3>
- *     <title>Collecting properties value</title>
- *     <para>#GProperty provides macros for collecting values from variable
- *     length arguments stored inside a <structname>va_list</structname>,
- *     similar to the %G_VALUE_COLLECT_INIT and %G_VALUE_LCOPY macros for
- *     #GValue. The %G_PROPERTY_COLLECT and %G_PROPERTY_LCOPY should be used
- *     to avoid the #GValue boxing and unboxing of their #GValue
- *     counterparts when collecting values and return locations for
- *     values.</para>
- *   </refsect3>
  * </refsect2>
  *
  * <refsect2>
@@ -4308,7 +4298,8 @@ g_property_override_default (GProperty *property,
  * g_property_set_valist:
  * @property: a #GProperty
  * @gobject: a #GObject instance
- * @args: the value to set, inside a va_list
+ * @flags: collection flags, as a bitwise or of #GPropertyCollectFlags values
+ * @args: the value to set, inside a pointer to a #va_list
  *
  * Sets the value of @property for the given #GObject instance.
  *
@@ -4319,9 +4310,10 @@ g_property_override_default (GProperty *property,
  * Since: 2.30
  */
 gboolean
-g_property_set_valist (GProperty *property,
-                       gpointer   gobject,
-                       va_list    args)
+g_property_set_valist (GProperty             *property,
+                       gpointer               gobject,
+                       GPropertyCollectFlags  flags,
+                       va_list               *args)
 {
   gboolean retval;
   GType gtype;
@@ -4337,97 +4329,97 @@ g_property_set_valist (GProperty *property,
   switch (G_TYPE_FUNDAMENTAL (gtype))
     {
     case G_TYPE_BOOLEAN:
-      retval = g_boolean_property_set_value (property, gobject, va_arg (args, gboolean));
+      retval = g_boolean_property_set_value (property, gobject, va_arg (*args, gboolean));
       break;
 
     case G_TYPE_INT:
       switch (property->type_size)
         {
         case 1:
-          retval = g_int8_property_set_value (property, gobject, va_arg (args, gint));
+          retval = g_int8_property_set_value (property, gobject, va_arg (*args, gint));
           break;
 
         case 2:
-          retval = g_int16_property_set_value (property, gobject, va_arg (args, gint));
+          retval = g_int16_property_set_value (property, gobject, va_arg (*args, gint));
           break;
 
         case 4:
-          retval = g_int32_property_set_value (property, gobject, va_arg (args, gint));
+          retval = g_int32_property_set_value (property, gobject, va_arg (*args, gint));
           break;
 
         default:
-          retval = g_int_property_set_value (property, gobject, va_arg (args, gint));
+          retval = g_int_property_set_value (property, gobject, va_arg (*args, gint));
           break;
         }
       break;
 
     case G_TYPE_INT64:
-      retval = g_int64_property_set_value (property, gobject, va_arg (args, gint64));
+      retval = g_int64_property_set_value (property, gobject, va_arg (*args, gint64));
       break;
 
     case G_TYPE_LONG:
-      retval = g_long_property_set_value (property, gobject, va_arg (args, glong));
+      retval = g_long_property_set_value (property, gobject, va_arg (*args, glong));
       break;
 
     case G_TYPE_UINT:
       switch (property->type_size)
         {
         case 1:
-          retval = g_uint8_property_set_value (property, gobject, va_arg (args, guint));
+          retval = g_uint8_property_set_value (property, gobject, va_arg (*args, guint));
           break;
 
         case 2:
-          retval = g_uint16_property_set_value (property, gobject, va_arg (args, guint));
+          retval = g_uint16_property_set_value (property, gobject, va_arg (*args, guint));
           break;
 
         case 4:
-          retval = g_uint32_property_set_value (property, gobject, va_arg (args, guint));
+          retval = g_uint32_property_set_value (property, gobject, va_arg (*args, guint));
           break;
 
         default:
-          retval = g_uint_property_set_value (property, gobject, va_arg (args, guint));
+          retval = g_uint_property_set_value (property, gobject, va_arg (*args, guint));
           break;
         }
       break;
 
     case G_TYPE_UINT64:
-      retval = g_uint64_property_set_value (property, gobject, va_arg (args, guint64));
+      retval = g_uint64_property_set_value (property, gobject, va_arg (*args, guint64));
       break;
 
     case G_TYPE_ULONG:
-      retval = g_ulong_property_set_value (property, gobject, va_arg (args, gulong));
+      retval = g_ulong_property_set_value (property, gobject, va_arg (*args, gulong));
       break;
 
     case G_TYPE_ENUM:
-      retval = g_enum_property_set_value (property, gobject, va_arg (args, glong));
+      retval = g_enum_property_set_value (property, gobject, va_arg (*args, glong));
       break;
 
     case G_TYPE_FLAGS:
-      retval = g_flags_property_set_value (property, gobject, va_arg (args, gulong));
+      retval = g_flags_property_set_value (property, gobject, va_arg (*args, gulong));
       break;
 
     case G_TYPE_FLOAT:
-      retval = g_float_property_set_value (property, gobject, va_arg (args, gdouble));
+      retval = g_float_property_set_value (property, gobject, va_arg (*args, gdouble));
       break;
 
     case G_TYPE_DOUBLE:
-      retval = g_double_property_set_value (property, gobject, va_arg (args, gdouble));
+      retval = g_double_property_set_value (property, gobject, va_arg (*args, gdouble));
       break;
 
     case G_TYPE_STRING:
-      retval = g_string_property_set_value (property, gobject, va_arg (args, gchar *));
+      retval = g_string_property_set_value (property, gobject, va_arg (*args, gchar *));
       break;
 
     case G_TYPE_BOXED:
-      retval = g_boxed_property_set_value (property, gobject, va_arg (args, gpointer));
+      retval = g_boxed_property_set_value (property, gobject, va_arg (*args, gpointer));
       break;
 
     case G_TYPE_OBJECT:
-      retval = g_object_property_set_value (property, gobject, va_arg (args, gpointer));
+      retval = g_object_property_set_value (property, gobject, va_arg (*args, gpointer));
       break;
 
     case G_TYPE_POINTER:
-      retval = g_pointer_property_set_value (property, gobject, va_arg (args, gpointer));
+      retval = g_pointer_property_set_value (property, gobject, va_arg (*args, gpointer));
       break;
 
     default:
@@ -4445,7 +4437,8 @@ g_property_set_valist (GProperty *property,
  * g_property_get_valist:
  * @property: a #GProperty
  * @gobject: a #GObject instance
- * @args: a va_list with the property
+ * @flags: collection flags
+ * @args: a pointer to a #va_list with the property
  *
  * Retrieves the value of @property for the given #GObject instance.
  *
@@ -4457,9 +4450,10 @@ g_property_set_valist (GProperty *property,
  * Since: 2.30
  */
 gboolean
-g_property_get_valist (GProperty *property,
-                       gpointer   gobject,
-                       va_list    args)
+g_property_get_valist (GProperty             *property,
+                       gpointer               gobject,
+                       GPropertyCollectFlags  flags,
+                       va_list               *args)
 {
   GType gtype;
   gpointer ret_p = NULL;
@@ -4470,7 +4464,13 @@ g_property_get_valist (GProperty *property,
 
   gtype = G_PARAM_SPEC (property)->value_type;
 
-  ret_p = va_arg (args, gpointer);
+  ret_p = va_arg (*args, gpointer);
+  if (ret_p == NULL)
+    {
+      g_critical (G_STRLOC ": value location for a property of type '%s' passed as NULL",
+                  g_type_name (gtype));
+      return FALSE;
+    }
 
   switch (G_TYPE_FUNDAMENTAL (gtype))
     {
@@ -4553,15 +4553,45 @@ g_property_get_valist (GProperty *property,
       break;
 
     case G_TYPE_STRING:
-      (* (gconstpointer *) ret_p) = g_string_property_get_value (property, gobject);
+      {
+        const gchar *value;
+
+        value = g_string_property_get_value (property, gobject);
+
+        if ((flags & G_PROPERTY_COLLECT_COPY) != 0)
+          (* (gchar **) ret_p) = g_strdup (value);
+        else
+          (* (gconstpointer *) ret_p) = value;
+      }
       break;
 
     case G_TYPE_BOXED:
-      (* (gpointer *) ret_p) = g_boxed_property_get_value (property, gobject);
+      {
+        gpointer boxed;
+
+        boxed = g_boxed_property_get_value (property, gobject);
+
+        if ((flags & G_PROPERTY_COLLECT_COPY) != 0)
+          {
+            if (boxed != NULL)
+              (* (gpointer *) ret_p) = g_boxed_copy (gtype, boxed);
+            else
+              (* (gpointer *) ret_p) = NULL;
+          }
+        else
+          (* (gpointer *) ret_p) = (gpointer) boxed;
+      }
       break;
 
     case G_TYPE_OBJECT:
-      (* (gpointer *) ret_p) = g_object_property_get_value (property, gobject);
+      {
+        gpointer obj = g_object_property_get_value (property, gobject);
+
+        if (((flags & G_PROPERTY_COLLECT_REF) != 0) && obj != NULL)
+          (* (gpointer *) ret_p) = g_object_ref (obj);
+        else
+          (* (gpointer *) ret_p) = obj;
+      }
       break;
 
     case G_TYPE_POINTER:
@@ -4570,7 +4600,7 @@ g_property_get_valist (GProperty *property,
 
     default:
       g_critical (G_STRLOC ": Invalid type %s", g_type_name (gtype));
-      break;
+      return FALSE;
     }
 
   return TRUE;
@@ -4597,439 +4627,13 @@ g_property_set (GProperty *property,
   gboolean res;
 
   va_start (args, gobject);
-  res = g_property_set_valist (property, gobject, args);
+  res = g_property_set_valist (property, gobject, 0, &args);
   va_end (args);
 
   return res;
 }
 
 /**
- * g_property_collect:
- * @property: a #GProperty
- * @gobject: a #GObject instance
- * @flags: collection flags
- * @n_cvalues: the number of C values in the @cvalues array
- * @cvalues: an array of C values
- *
- * Collects the values in the @cvalues array and sets them on @property
- * for the given #GObject instance.
- *
- * This function should only be called through the %G_PROPERTY_COLLECT
- * macro provided by the <filename>gvaluecollector.h</filename> header
- * and never directly.
- *
- * Return value: %TRUE if the collection was successful, and %FALSE
- *   otherwise
- *
- * Since: 2.30
- */
-gboolean
-g_property_collect (GProperty *property,
-                    gpointer   gobject,
-                    gulong     flags,
-                    guint      n_cvalues,
-                    gpointer   cvalues)
-{
-  GTypeCValue *_cvalues = cvalues;
-  GType gtype;
-  gint i;
-  gboolean retval = FALSE;
-
-  g_return_val_if_fail (G_IS_PROPERTY (property), FALSE);
-  g_return_val_if_fail (G_IS_OBJECT (gobject), FALSE);
-
-  gtype = G_PARAM_SPEC (property)->value_type;
-
-  for (i = 0; i < n_cvalues; i++)
-    {
-      GTypeCValue *_cvalue = _cvalues + i;
-
-      switch (G_TYPE_FUNDAMENTAL (gtype))
-        {
-        case G_TYPE_BOOLEAN:
-          retval = g_boolean_property_set_value (property, gobject, _cvalue->v_int != 0 ? TRUE : FALSE);
-          break;
-
-        case G_TYPE_INT:
-        case G_TYPE_UINT:
-          switch (property->type_size)
-            {
-            case 1:
-              if (G_TYPE_FUNDAMENTAL (gtype) == G_TYPE_INT)
-                retval = g_int8_property_set_value (property, gobject, _cvalue->v_int);
-              else
-                retval = g_uint8_property_set_value (property, gobject, _cvalue->v_int);
-              break;
-
-            case 2:
-              if (G_TYPE_FUNDAMENTAL (gtype) == G_TYPE_INT)
-                retval = g_int16_property_set_value (property, gobject, _cvalue->v_int);
-              else
-                retval = g_uint16_property_set_value (property, gobject, _cvalue->v_int);
-              break;
-
-            case 4:
-              if (G_TYPE_FUNDAMENTAL (gtype) == G_TYPE_INT)
-                retval = g_int32_property_set_value (property, gobject, _cvalue->v_int);
-              else
-                retval = g_uint32_property_set_value (property, gobject, _cvalue->v_int);
-              break;
-
-            default:
-              if (G_TYPE_FUNDAMENTAL (gtype) == G_TYPE_INT)
-                retval = g_int_property_set_value (property, gobject, _cvalue->v_int);
-              else
-                retval = g_uint_property_set_value (property, gobject, _cvalue->v_int);
-              break;
-            }
-          break;
-
-        case G_TYPE_INT64:
-          retval = g_int64_property_set_value (property, gobject, _cvalue->v_int64);
-          break;
-
-        case G_TYPE_UINT64:
-          retval = g_uint64_property_set_value (property, gobject, _cvalue->v_int64);
-          break;
-
-        case G_TYPE_LONG:
-          retval = g_long_property_set_value (property, gobject, _cvalue->v_long);
-          break;
-
-        case G_TYPE_ULONG:
-          retval = g_ulong_property_set_value (property, gobject, _cvalue->v_long);
-          break;
-
-        case G_TYPE_ENUM:
-          retval = g_enum_property_set_value (property, gobject, _cvalue->v_long);
-          break;
-
-        case G_TYPE_FLAGS:
-          retval = g_flags_property_set_value (property, gobject, _cvalue->v_long);
-          break;
-
-        case G_TYPE_FLOAT:
-          retval = g_float_property_set_value (property, gobject, _cvalue->v_double);
-          break;
-
-        case G_TYPE_DOUBLE:
-          retval = g_double_property_set_value (property, gobject, _cvalue->v_double);
-          break;
-
-        case G_TYPE_STRING:
-          retval = g_string_property_set_value (property, gobject, _cvalue->v_pointer);
-          break;
-
-        case G_TYPE_BOXED:
-          retval = g_boxed_property_set_value (property, gobject, _cvalue->v_pointer);
-          break;
-
-        case G_TYPE_OBJECT:
-          retval = g_object_property_set_value (property, gobject, _cvalue->v_pointer);
-          break;
-
-        case G_TYPE_POINTER:
-          retval = g_pointer_property_set_value (property, gobject, _cvalue->v_pointer);
-          break;
-
-        default:
-          g_critical (G_STRLOC ": Invalid value for type '%s'", g_type_name (gtype));
-          retval = FALSE;
-        }
-    }
-
-  return retval;
-}
-
-/**
- * g_property_lcopy:
- * @property: a #GProperty
- * @gobject: a #GObject instance
- * @n_cvalues: the number of C values in the @cvalues array
- * @cvalues: an array of C values
- *
- * Copies the value of @property for the given #GObject instance into
- * the passed array of C values.
- *
- * This function should only be called through the %G_PROPERTY_LCOPY
- * macro provided by the <filename>gvaluecollector.h</filename> header
- * and never directly.
- *
- *
- * Return value: %TRUE if the collection was successful, and %FALSE
- *   otherwise
- *
- * Since: 2.30
- */
-gboolean
-g_property_lcopy (GProperty *property,
-                  gpointer   gobject,
-                  gulong     flags,
-                  guint      n_cvalues,
-                  gpointer   cvalues)
-{
-  GTypeCValue *_cvalues = cvalues;
-  GType gtype;
-  gint i;
-
-  g_return_val_if_fail (G_IS_PROPERTY (property), FALSE);
-  g_return_val_if_fail (G_IS_OBJECT (gobject), FALSE);
-
-  gtype = G_PARAM_SPEC (property)->value_type;
-
-  for (i = 0; i < n_cvalues; i++)
-    {
-      GTypeCValue *_cvalue = _cvalues + i;
-
-      switch (G_TYPE_FUNDAMENTAL (gtype))
-        {
-        case G_TYPE_BOOLEAN:
-          {
-            gboolean *val = _cvalue->v_pointer;
-            if (val != NULL)
-              *val = g_boolean_property_get_value (property, gobject);
-            else
-              {
-                g_critical (G_STRLOC ": value location for gboolean passed as NULL");
-                return FALSE;
-              }
-          }
-          break;
-
-        case G_TYPE_INT:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gint passed as NULL");
-              return FALSE;
-            }
-
-          switch (property->type_size)
-            {
-            case 1:
-              (* (gint8 *) _cvalue->v_pointer) =
-                g_int8_property_get_value (property, gobject);
-              break;
-
-            case 2:
-              (* (gint16 *) _cvalue->v_pointer) =
-                g_int16_property_get_value (property, gobject);
-              break;
-
-            case 4:
-              (* (gint32 *) _cvalue->v_pointer) =
-                g_int32_property_get_value (property, gobject);
-              break;
-
-            default:
-              (* (gint *) _cvalue->v_pointer) =
-                g_int_property_get_value (property, gobject);
-              break;
-            }
-          break;
-
-        case G_TYPE_UINT:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for guint passed as NULL");
-              return FALSE;
-            }
-
-          switch (property->type_size)
-            {
-            case 1:
-              (* (guint8 *) _cvalue->v_pointer) =
-                g_uint8_property_get_value (property, gobject);
-              break;
-
-            case 2:
-              (* (guint16 *) _cvalue->v_pointer) =
-                g_uint16_property_get_value (property, gobject);
-              break;
-
-            case 4:
-              (* (guint32 *) _cvalue->v_pointer) =
-                g_uint32_property_get_value (property, gobject);
-              break;
-
-            default:
-              (* (guint *) _cvalue->v_pointer) =
-                g_uint_property_get_value (property, gobject);
-              break;
-            }
-          break;
-
-        case G_TYPE_INT64:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gint64 passed as NULL");
-              return FALSE;
-            }
-
-          (* (gint64 *) _cvalue->v_pointer) =
-            g_int64_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_UINT64:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for guint64 passed as NULL");
-              return FALSE;
-            }
-
-          (* (guint64 *) _cvalue->v_pointer) =
-            g_uint64_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_LONG:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for glong passed as NULL");
-              return FALSE;
-            }
-
-          (* (glong *) _cvalue->v_pointer) =
-            g_long_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_ULONG:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gulong passed as NULL");
-              return FALSE;
-            }
-
-          (* (gulong *) _cvalue->v_pointer) =
-            g_ulong_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_ENUM:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for GEnum passed as NULL");
-              return FALSE;
-            }
-
-          (* (glong *) _cvalue->v_pointer) =
-            g_enum_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_FLAGS:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for GFlags passed as NULL");
-              return FALSE;
-            }
-
-          (* (gulong *) _cvalue->v_pointer) =
-            g_flags_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_FLOAT:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gfloat passed as NULL");
-              return FALSE;
-            }
-
-          (* (gfloat *) _cvalue->v_pointer) =
-            g_float_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_DOUBLE:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gdouble passed as NULL");
-              return FALSE;
-            }
-
-          (* (gdouble *) _cvalue->v_pointer) =
-            g_double_property_get_value (property, gobject);
-          break;
-
-        case G_TYPE_STRING:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for string passed as NULL");
-              return FALSE;
-            }
-
-          if ((flags & G_PROPERTY_COLLECT_COPY) != 0)
-            {
-              (* (gchar **) _cvalue->v_pointer) =
-                (gchar *) g_strdup (g_string_property_get_value (property, gobject));
-            }
-          else
-            {
-              (* (gchar **) _cvalue->v_pointer) =
-                (gchar *) g_string_property_get_value (property, gobject);
-            }
-          break;
-
-        case G_TYPE_BOXED:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for %s passed as NULL",
-                          g_type_name (gtype));
-              return FALSE;
-            }
-          else
-            {
-              gconstpointer boxed;
-
-              boxed = g_boxed_property_get_value (property, gobject);
-
-              if ((flags & G_PROPERTY_COLLECT_COPY) != 0)
-                {
-                  if (boxed != NULL)
-                    (* (gpointer *) _cvalue->v_pointer) = g_boxed_copy (gtype, boxed);
-                  else
-                    (* (gpointer *) _cvalue->v_pointer) = NULL;
-                }
-              else
-                (* (gpointer *) _cvalue->v_pointer) = (gpointer) boxed;
-            }
-          break;
-
-        case G_TYPE_OBJECT:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for %s passed as NULL",
-                          g_type_name (gtype));
-              return FALSE;
-            }
-          else
-            {
-              gpointer obj = g_object_property_get_value (property, gobject);
-
-              if (((flags & G_PROPERTY_COLLECT_REF) != 0) && obj != NULL)
-                (* (gpointer *) _cvalue->v_pointer) = g_object_ref (obj);
-              else
-                (* (gpointer *) _cvalue->v_pointer) = obj;
-            }
-          break;
-
-        case G_TYPE_POINTER:
-          if (_cvalue->v_pointer == NULL)
-            {
-              g_critical (G_STRLOC ": value location for gpointer passed as NULL");
-              return FALSE;
-            }
-
-          (* (gpointer *) _cvalue->v_pointer) =
-            g_pointer_property_get_value (property, gobject);
-          break;
-
-        default:
-          g_critical (G_STRLOC ": Invalid value location for type '%s'",
-                      g_type_name (gtype));
-          return FALSE;
-        }
-    }
-
-  return TRUE;
-}
-
-/**
  * g_property_get:
  * @property: a #GProperty
  * @gobject: a #GObject instance
@@ -5037,8 +4641,6 @@ g_property_lcopy (GProperty *property,
  *
  * Retrieves the value of the @property for the given #GObject instance.
  *
- * The value will either be copied or have its reference count increased.
- *
  * Since: 2.30
  */
 gboolean
@@ -5050,7 +4652,7 @@ g_property_get (GProperty *property,
   gboolean retval;
 
   va_start (args, gobject);
-  retval = g_property_get_valist (property, gobject, args);
+  retval = g_property_get_valist (property, gobject, 0, &args);
   va_end (args);
 
   return retval;
diff --git a/gobject/gproperty.h b/gobject/gproperty.h
index ebb8ae0..c156563 100644
--- a/gobject/gproperty.h
+++ b/gobject/gproperty.h
@@ -134,12 +134,6 @@ void            g_property_set_value                    (GProperty    *property,
 void            g_property_get_value                    (GProperty    *property,
                                                          gpointer      gobject,
                                                          GValue       *value);
-gboolean        g_property_set_valist                   (GProperty    *property,
-                                                         gpointer      gobject,
-                                                         va_list       args);
-gboolean        g_property_get_valist                   (GProperty    *property,
-                                                         gpointer      gobject,
-                                                         va_list       args);
 gboolean        g_property_set                          (GProperty    *property,
                                                          gpointer      gobject,
                                                          ...);
@@ -147,19 +141,33 @@ gboolean        g_property_get                          (GProperty    *property,
                                                          gpointer      gobject,
                                                          ...);
 
-/* va_list collection/copy API; see gvaluecollector.h for
- * the macros and types to use
+/**
+ * GPropertyCollectFlags:
+ * @G_PROPERTY_COLLECT_NONE: No flags
+ * @G_PROPERTY_COLLECT_COPY: Make a copy when collecting pointer
+ *   locations for boxed and string values
+ * @G_PROPERTY_COLLECT_REF: Take a reference when collecting
+ *   pointer locations for object values
+ *
+ * Flags to pass to g_property_collect() and g_property_lcopy().
+ *
+ * Since: 2.32
  */
-gboolean        g_property_collect                      (GProperty    *property,
-                                                         gpointer      gobject,
-                                                         gulong        flags,
-                                                         guint         n_cvalues,
-                                                         gpointer      cvalues);
-gboolean        g_property_lcopy                        (GProperty    *property,
-                                                         gpointer      gobject,
-                                                         gulong        flags,
-                                                         guint         n_cvalues,
-                                                         gpointer      cvalues);
+typedef enum { /*< prefix=G_PROPERTY_COLLECT >*/
+  G_PROPERTY_COLLECT_NONE = 0,
+
+  G_PROPERTY_COLLECT_COPY = 1 << 0,
+  G_PROPERTY_COLLECT_REF  = 1 << 1
+} GPropertyCollectFlags;
+
+gboolean        g_property_set_valist   (GProperty             *property,
+                                         gpointer               gobject,
+                                         GPropertyCollectFlags  flags,
+                                         va_list               *app);
+gboolean        g_property_get_valist   (GProperty             *property,
+                                         gpointer               gobject,
+                                         GPropertyCollectFlags  flags,
+                                         va_list               *app);
 
 typedef void (* GPropertyLockFunc)   (GProperty *property,
                                       gpointer   gobject);
diff --git a/gobject/gvaluecollector.h b/gobject/gvaluecollector.h
index ab10077..05a436a 100644
--- a/gobject/gvaluecollector.h
+++ b/gobject/gvaluecollector.h
@@ -251,124 +251,6 @@ G_STMT_START {										\
  */
 #define	G_VALUE_COLLECT_FORMAT_MAX_LENGTH	(8)
 
-/**
- * GPropertyCollectFlags:
- * @G_PROPERTY_COLLECT_NONE: No flags
- * @G_PROPERTY_COLLECT_COPY: Make a copy when collecting pointer
- *   locations for boxed and string values
- * @G_PROPERTY_COLLECT_REF: Take a reference while collecting
- *   pointer locations for object values
- *
- * Flags to pass to %G_PROPERTY_LCOPY and %G_PROPERTY_COLLECT.
- *
- * Since: 2.32
- */
-typedef enum { /*< prefix=G_PROPERTY_COLLECT >*/
-  G_PROPERTY_COLLECT_NONE = 0,
-
-  G_PROPERTY_COLLECT_COPY = 1 << 0,
-  G_PROPERTY_COLLECT_REF  = 1 << 1
-} GPropertyCollectFlags;
-
-/**
- * G_PROPERTY_LCOPY:
- * @property: a #GProperty
- * @gobject: a #GObject
- * @flags: flags for collection
- * @var_args: the va_list variable; it may be evaluated multiple times
- * @__retval: the address of a #gboolean variable, which will be set
- *   to %FALSE if the copy was not successful
- *
- * Collects a variable argument value from a va_list and sets it for
- * the given #GProperty.
- *
- * We have to implement the varargs collection as a macro, because on some
- * systems va_list variables cannot be passed by reference.
- */
-#define G_PROPERTY_COLLECT(property, gobject, flags, var_args, __retval)        G_STMT_START {  \
-  GType _p_type = g_property_get_value_type ((property)); \
-  GTypeValueTable *_vtab = g_type_value_table_peek (_p_type); \
-  gchar *_collect_format = _vtab->collect_format; \
-  GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
-  guint _n_values = 0; \
-\
-  while (*_collect_format) \
-    { \
-      GTypeCValue *_cvalue = _cvalues + _n_values++; \
-\
-      switch (*_collect_format++) \
-        { \
-        case G_VALUE_COLLECT_INT: \
-          _cvalue->v_int = va_arg ((var_args), gint); \
-          break; \
-        case G_VALUE_COLLECT_LONG: \
-          _cvalue->v_long = va_arg ((var_args), glong); \
-          break; \
-        case G_VALUE_COLLECT_INT64: \
-          _cvalue->v_int64 = va_arg ((var_args), gint64); \
-          break; \
-        case G_VALUE_COLLECT_DOUBLE: \
-          _cvalue->v_double = va_arg ((var_args), gdouble); \
-          break; \
-        case G_VALUE_COLLECT_POINTER: \
-          _cvalue->v_pointer = va_arg ((var_args), gpointer); \
-          break; \
-        default: \
-          g_assert_not_reached (); \
-        } \
-    } \
-\
-  *(__retval) = \
-    g_property_collect ((property), (gobject), (flags), _n_values, _cvalues);   } G_STMT_END
-
-/**
- * G_PROPERTY_LCOPY:
- * @property: a #GProperty
- * @gobject: a #GObject
- * @flags: flags for collection
- * @var_args: the va_list variable; it may be evaluated multiple times
- * @__retval: the address of a #gboolean variable, which will be set
- *   to %FALSE if the copy was not successful
- *
- * Collects a property value and places it into the variable argument location
- * from a va_list. Usage is analogous to G_PROPERTY_COLLECT().
- */
-#define G_PROPERTY_LCOPY(property, gobject, flags, var_args, __retval)          G_STMT_START {  \
-  GType _p_type = g_property_get_value_type ((property)); \
-  GTypeValueTable *_vtab = g_type_value_table_peek (_p_type); \
-  gchar *_lcopy_format = _vtab->lcopy_format; \
-  GTypeCValue _cvalues[G_VALUE_COLLECT_FORMAT_MAX_LENGTH] = { { 0, }, }; \
-  guint _n_values = 0; \
-\
-  while (*_lcopy_format) \
-    { \
-      GTypeCValue *_cvalue = _cvalues + _n_values++; \
-\
-      switch (*_lcopy_format++) \
-        { \
-        case G_VALUE_COLLECT_INT: \
-          _cvalue->v_int = va_arg ((var_args), gint); \
-          break; \
-        case G_VALUE_COLLECT_LONG: \
-          _cvalue->v_long = va_arg ((var_args), glong); \
-          break; \
-        case G_VALUE_COLLECT_INT64: \
-          _cvalue->v_int64 = va_arg ((var_args), gint64); \
-          break; \
-        case G_VALUE_COLLECT_DOUBLE: \
-          _cvalue->v_double = va_arg ((var_args), gdouble); \
-          break; \
-        case G_VALUE_COLLECT_POINTER: \
-          _cvalue->v_pointer = va_arg ((var_args), gpointer); \
-          break; \
-        default: \
-          g_assert_not_reached (); \
-        } \
-    } \
-\
-  *(__retval) = \
-    g_property_lcopy ((property), (object), (flags), _n_values, _cvalues);      } G_STMT_END
-
 G_END_DECLS
 
 #endif /* __G_VALUE_COLLECTOR_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]