From: Martin Ling Date: Sat, 19 Jul 2014 14:10:25 +0000 (+0100) Subject: Fix building Python bindings with pygobject >= 3.7.91. X-Git-Tag: libsigrok-0.4.0~1245 X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=abc7146d032d41af41e8bd20ea64554021e86656 Fix building Python bindings with pygobject >= 3.7.91. --- diff --git a/bindings/python/sigrok/core/classes.i b/bindings/python/sigrok/core/classes.i index f8620abe..374996d5 100644 --- a/bindings/python/sigrok/core/classes.i +++ b/bindings/python/sigrok/core/classes.i @@ -26,6 +26,14 @@ PyObject *GLib; PyTypeObject *IOChannel; PyTypeObject *PollFD; +#include "../../../../config.h" + +#if PYGOBJECT_FLAGS_SIGNED +typedef gint pyg_flags_type; +#else +typedef guint pyg_flags_type; +#endif + %} %init %{ @@ -64,7 +72,7 @@ PyTypeObject *PollFD; /* Map from Glib::IOCondition to GLib.IOCondition. */ %typecheck(SWIG_TYPECHECK_POINTER) Glib::IOCondition { - gint flags; + pyg_flags_type flags; $1 = pygobject_check($input, &PyGFlags_Type) && (pyg_flags_get_value(G_TYPE_IO_CONDITION, $input, &flags) != -1); } @@ -72,7 +80,7 @@ PyTypeObject *PollFD; %typemap(in) Glib::IOCondition { if (!pygobject_check($input, &PyGFlags_Type)) SWIG_exception(SWIG_TypeError, "Expected GLib.IOCondition value"); - gint flags; + pyg_flags_type flags; if (pyg_flags_get_value(G_TYPE_IO_CONDITION, $input, &flags) == -1) SWIG_exception(SWIG_TypeError, "Not a valid Glib.IOCondition value"); $1 = (Glib::IOCondition) flags; @@ -97,7 +105,7 @@ PyTypeObject *PollFD; SWIG_exception(SWIG_TypeError, "Expected GLib.PollFD"); PyObject *fd_obj = PyObject_GetAttrString($input, "fd"); PyObject *events_obj = PyObject_GetAttrString($input, "events"); - gint flags; + pyg_flags_type flags; pyg_flags_get_value(G_TYPE_IO_CONDITION, events_obj, &flags); int fd = PyInt_AsLong(fd_obj); Glib::IOCondition events = (Glib::IOCondition) flags; diff --git a/configure.ac b/configure.ac index 690dc2c6..971f9a7e 100644 --- a/configure.ac +++ b/configure.ac @@ -367,7 +367,12 @@ PKG_CHECK_MODULES([glibmm], [glibmm-2.4 >= 2.32.0], # PyGObject is needed for the Python bindings. PKG_CHECK_MODULES([pygobject], [pygobject-3.0], [CXXFLAGS="$CXXFLAGS $pygobject_CFLAGS"; - CXXLIBS="$CXXLIBS $pygobject_LIBS"], [BINDINGS_PYTHON="no"]) + CXXLIBS="$CXXLIBS $pygobject_LIBS"; + PKG_CHECK_MODULES([pygobject_3_7_91], [pygobject-3.0 >= 3.7.91], + [pyg_flags_signed=0], [pyg_flags_signed=1]); + AC_DEFINE_UNQUOTED(PYGOBJECT_FLAGS_SIGNED, [$pyg_flags_signed], + [Whether last argument to pyg_flags_get_value() is signed])], + [BINDINGS_PYTHON="no"]) # The Check unit testing framework is optional. Disable if not found. PKG_CHECK_MODULES([check], [check >= 0.9.4],