[pygobject] Ignore GValueArray deprecations



commit ee84b5a2c83d88436aec6b62e7a271a3525569e0
Author: Simon Feltman <sfeltman src gnome org>
Date:   Mon Mar 24 18:57:56 2014 -0700

    Ignore GValueArray deprecations
    
    Wrap calls to GValueArray related calls with G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS.
    Although GValueArray is deprecated, we still need to support the marshaling of
    them in PyGObject. The deprecations add noise to the build processes in which
    new warnings could be lost. Essentially losing the element of surprise a new
    warning should have on maintainers.

 gi/pygi-value.c          |   23 ++++++++++++++++++++---
 tests/testhelpermodule.c |    3 +++
 2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index f2cc27b..8235116 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -147,6 +147,11 @@ _pygi_argument_from_g_value(const GValue *value,
 }
 
 
+/* Ignore g_value_array deprecations. Although they are deprecated,
+ * we still need to support the marshaling of them in PyGObject.
+ */
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 static int
 pyg_value_array_from_pyobject(GValue *value,
                               PyObject *obj,
@@ -213,6 +218,8 @@ pyg_value_array_from_pyobject(GValue *value,
     return 0;
 }
 
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 static int
 pyg_array_from_pyobject(GValue *value,
                         PyObject *obj)
@@ -489,6 +496,11 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
         break;
     case G_TYPE_BOXED: {
         PyGTypeMarshal *bm;
+        gboolean holds_value_array;
+
+        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+        holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+        G_GNUC_END_IGNORE_DEPRECATIONS
 
         if (obj == Py_None)
             g_value_set_boxed(value, NULL);
@@ -510,9 +522,9 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
             g_value_take_boxed (value, n_value);
             return pyg_value_from_pyobject_with_error (n_value, obj);
         }
-        else if (PySequence_Check(obj) &&
-                G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY))
+        else if (PySequence_Check(obj) && holds_value_array)
             return pyg_value_array_from_pyobject(value, obj, NULL);
+
         else if (PySequence_Check(obj) &&
                 G_VALUE_HOLDS(value, G_TYPE_ARRAY))
             return pyg_array_from_pyobject(value, obj);
@@ -718,6 +730,11 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed)
                     g_value_get_pointer(value));
     case G_TYPE_BOXED: {
         PyGTypeMarshal *bm;
+        gboolean holds_value_array;
+
+        G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+        holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+        G_GNUC_END_IGNORE_DEPRECATIONS
 
         if (G_VALUE_HOLDS(value, PY_TYPE_OBJECT)) {
             PyObject *ret = (PyObject *)g_value_dup_boxed(value);
@@ -729,7 +746,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed)
         } else if (G_VALUE_HOLDS(value, G_TYPE_VALUE)) {
             GValue *n_value = g_value_get_boxed (value);
             return pyg_value_as_pyobject(n_value, copy_boxed);
-        } else if (G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY)) {
+        } else if (holds_value_array) {
             GValueArray *array = (GValueArray *) g_value_get_boxed(value);
             PyObject *ret = PyList_New(array->n_values);
             int i;
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index 9b198c3..66c0155 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -513,7 +513,10 @@ _wrap_test_value_array(PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple(args, "O", &obj))
     return NULL;
 
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   g_value_init(value, G_TYPE_VALUE_ARRAY);
+  G_GNUC_END_IGNORE_DEPRECATIONS
+
   if (pyg_value_from_pyobject(value, obj)) {
     PyErr_SetString(PyExc_TypeError, "Could not convert to GValueArray");
     return NULL;


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