[pygobject] Avoid various new glib deprecation warnings



commit 783ee44661fa3ce3cceb67ac8eaabae4e06e3290
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Fri Oct 4 17:45:55 2019 +0200

    Avoid various new glib deprecation warnings
    
    This should make things build with -Werror again once we port things
    to g_object_new_with_properties()

 gi/gimodule.c            |  4 ++++
 gi/pygi-info.c           |  2 +-
 gi/pygi-type.c           |  2 +-
 gi/pygi-value.c          | 16 ++++++++++++----
 tests/testhelpermodule.c | 11 ++++++++---
 5 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index c9b29f5a..4cba06e2 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -460,6 +460,8 @@ pyg_param_spec_from_object (PyObject *tuple)
     return pspec;
 }
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 /**
  * pyg_parse_constructor_args: helper function for PyGObject constructors
  * @obj_type: GType of the GObject, for parameter introspection
@@ -514,6 +516,8 @@ pyg_parse_constructor_args(GType        obj_type,
     return TRUE;
 }
 
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 /* Only for backwards compatibility */
 static int
 pygobject_enable_threads(void)
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 94564ed7..0c4824ff 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -2080,7 +2080,7 @@ _wrap_g_field_info_set_value (PyGIBaseInfo *self,
                 size = g_struct_info_get_size ( (GIStructInfo *) info);
                 g_assert (size > 0);
 
-                g_memmove ((char*) pointer + offset, value.v_pointer, size);
+                memmove ((char*) pointer + offset, value.v_pointer, size);
 
                 g_base_info_unref (info);
 
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index 3ca0fc82..952d3079 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -1162,7 +1162,7 @@ add_property_docs(GType gtype, GString *string)
     GParamSpec **props;
     guint n_props = 0, i;
     gboolean has_prop = FALSE;
-    G_CONST_RETURN gchar *blurb=NULL;
+    const gchar *blurb=NULL;
 
     class = g_type_class_ref(gtype);
     props = g_object_class_list_properties(class, &n_props);
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index 8376231e..0c54c3e3 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -30,6 +30,11 @@
 #include "pygparamspec.h"
 
 
+/* glib 2.62 has started to print warnings for these which can't be disabled selectively, so just copy them 
here */
+#define PYGI_TYPE_VALUE_ARRAY (g_value_array_get_type())
+#define PYGI_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), PYGI_TYPE_VALUE_ARRAY))
+#define PYGI_PARAM_SPEC_VALUE_ARRAY(pspec)    (G_TYPE_CHECK_INSTANCE_CAST ((pspec), g_param_spec_types[18], 
GParamSpecValueArray))
+
 GIArgument
 _pygi_argument_from_g_value(const GValue *value,
                             GITypeInfo *type_info)
@@ -502,7 +507,7 @@ pyg_value_from_pyobject_with_error(GValue *value, PyObject *obj)
         gboolean holds_value_array;
 
         G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-        holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+        holds_value_array = G_VALUE_HOLDS(value, PYGI_TYPE_VALUE_ARRAY);
         G_GNUC_END_IGNORE_DEPRECATIONS
 
         if (obj == Py_None)
@@ -718,7 +723,7 @@ value_to_py_structured_type (const GValue *value, GType fundamental, gboolean co
         gboolean holds_value_array;
 
         G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-        holds_value_array = G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY);
+        holds_value_array = G_VALUE_HOLDS(value, PYGI_TYPE_VALUE_ARRAY);
         G_GNUC_END_IGNORE_DEPRECATIONS
 
         if (G_VALUE_HOLDS(value, PY_TYPE_OBJECT)) {
@@ -826,6 +831,7 @@ pyg_value_as_pyobject (const GValue *value, gboolean copy_boxed)
 }
 
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 int
 pyg_param_gvalue_from_pyobject(GValue* value,
                                PyObject* py_obj,
@@ -841,14 +847,16 @@ pyg_param_gvalue_from_pyobject(GValue* value,
         g_value_set_uint(value, u);
        return 0;
     }
-    else if (G_IS_PARAM_SPEC_VALUE_ARRAY(pspec))
+    else if (PYGI_IS_PARAM_SPEC_VALUE_ARRAY(pspec))
        return pyg_value_array_from_pyobject(value, py_obj,
-                                            G_PARAM_SPEC_VALUE_ARRAY(pspec));
+                                            PYGI_PARAM_SPEC_VALUE_ARRAY(pspec));
     else {
        return pyg_value_from_pyobject(value, py_obj);
     }
 }
 
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 PyObject*
 pyg_param_gvalue_as_pyobject(const GValue* gvalue,
                              gboolean copy_boxed,
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index e26a004b..82b0399e 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -513,6 +513,8 @@ _wrap_test_state_ensure_release(PyObject *self, PyObject *args)
     Py_RETURN_NONE;
 }
 
+#define PYGI_TYPE_VALUE_ARRAY (g_value_array_get_type())
+
 static PyObject *
 _wrap_test_value_array(PyObject *self, PyObject *args)
 {
@@ -523,7 +525,7 @@ _wrap_test_value_array(PyObject *self, PyObject *args)
     return NULL;
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  g_value_init(value, G_TYPE_VALUE_ARRAY);
+  g_value_init(value, PYGI_TYPE_VALUE_ARRAY);
   G_GNUC_END_IGNORE_DEPRECATIONS
 
   if (pyg_value_from_pyobject(value, obj)) {
@@ -550,9 +552,9 @@ _wrap_value_array_get_nth_type(PyObject *self, PyObject *args)
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
   if (pyg_boxed_check(obj, G_TYPE_VALUE) &&
-      G_VALUE_HOLDS(pyg_boxed_get(obj, GValue), G_TYPE_VALUE_ARRAY)) {
+      G_VALUE_HOLDS(pyg_boxed_get(obj, GValue), PYGI_TYPE_VALUE_ARRAY)) {
     arr = g_value_get_boxed(pyg_boxed_get(obj, GValue));
-  } else if (pyg_boxed_check(obj, G_TYPE_VALUE_ARRAY)) {
+  } else if (pyg_boxed_check(obj, PYGI_TYPE_VALUE_ARRAY)) {
     arr = pyg_boxed_get(obj, GValueArray);
   } else {
     PyErr_SetString(PyExc_TypeError, "First argument is not GValueArray");
@@ -655,6 +657,7 @@ _wrap_test_floating_and_sunk_get_instance_list (PyObject *self)
     return py_list;
 }
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
 static PyObject *
 _wrap_test_parse_constructor_args (PyObject *self, PyObject *args)
@@ -676,6 +679,8 @@ _wrap_test_parse_constructor_args (PyObject *self, PyObject *args)
     return PYGLIB_PyLong_FromLong (nparams);
 }
 
+G_GNUC_END_IGNORE_DEPRECATIONS
+
 static PyObject *
 _wrap_test_to_unichar_conv (PyObject * self, PyObject *args)
 {


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