diff options
-rw-r--r-- | ChangeLog | 350 | ||||
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | Makefile.in | 1 | ||||
-rw-r--r-- | NEWS | 19 | ||||
-rw-r--r-- | PKG-INFO | 4 | ||||
-rw-r--r-- | aclocal.m4 | 1066 | ||||
-rwxr-xr-x | configure | 36 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gi/_gobject/gobjectmodule.c | 1 | ||||
-rw-r--r-- | gi/_gobject/propertyhelper.py | 6 | ||||
-rw-r--r-- | gi/_gobject/pygtype.c | 12 | ||||
-rw-r--r-- | gi/overrides/GLib.py | 34 | ||||
-rw-r--r-- | gi/pygi-argument.c | 6 | ||||
-rw-r--r-- | gi/pygi-cache.c | 2 | ||||
-rw-r--r-- | gi/pygi-invoke.c | 57 | ||||
-rw-r--r-- | ltmain.sh | 4 | ||||
-rw-r--r-- | m4/libtool.m4 | 12 | ||||
-rwxr-xr-x | pygi-convert.sh | 350 | ||||
-rw-r--r-- | pygtkcompat/pygtkcompat.py | 7 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/Makefile.in | 1 | ||||
-rw-r--r-- | tests/test_gdbus.py | 4 | ||||
-rw-r--r-- | tests/test_gi.py | 67 | ||||
-rw-r--r-- | tests/test_glib.py | 13 | ||||
-rw-r--r-- | tests/test_internal_api.py | 73 | ||||
-rw-r--r-- | tests/test_overrides_gtk.py | 12 | ||||
-rw-r--r-- | tests/test_properties.py | 11 |
27 files changed, 1530 insertions, 622 deletions
@@ -1,3 +1,353 @@ +commit 061b23d14386c0e54d2c3af113554231bbe85f16 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 23:18:31 2012 +0100 + + release 3.7.3 + + NEWS | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +commit a242f02823a63c9dca5d0b1ce84b031221053690 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 23:11:29 2012 +0100 + + Add (failing) tests for callbacks with out arguments + + Most of these fail and need marshalling fixes. + + tests/test_gi.py | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +commit 449b1ef0d94450c1e457770a093abd6d6c9e6291 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 22:50:59 2012 +0100 + + Add tests for internal API + + These cover functions like pygobject_new(), pyg_value_from_pyobject() + and + pyg_value_as_pyobject() that are wrapped by testhelpermodule.c. With + that these + functions can be tested in isolation without the whole GI stack + around them. + + tests/Makefile.am | 1 + + tests/test_internal_api.py | 73 + ++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 74 insertions(+) + +commit e44312139426f51e576ef9e880819542cc224383 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 18:02:15 2012 +0100 + + Add support for caller-allocated GArray out arguments + + https://bugzilla.gnome.org/show_bug.cgi?id=690041 + + gi/pygi-cache.c | 2 +- + gi/pygi-invoke.c | 57 + ++++++++++++++++++++++++++++++-------------------------- + tests/test_gi.py | 5 +++-- + 3 files changed, 35 insertions(+), 29 deletions(-) + +commit f262320ac22b48a9d007c425633f3ca426b7fb4a +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 16:18:24 2012 +0100 + + Add (failing) test for caller-allocated GArray return value + + Call new GIMarshallingTests.garray_utf8_full_out_caller_allocated() + function + which reproduces https://bugzilla.gnome.org/show_bug.cgi?id=690041. + + The test is failing and causing a segfault right now, so disable it + until this + actually works. + + tests/test_gi.py | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 1cb4c30c3cf19690210010d39b6272965f489c58 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Dec 17 15:56:44 2012 +0100 + + GLib overrides: Avoid calling deprecated GLib.unix_signal_add_full() + + glib 2.35.x fixed the API to be GLib.unix_signal_add(). Call the + modern API if + available, but fall back to GLib.unix_signal_add_full() until we + depend on glib + 2.36. + + gi/overrides/GLib.py | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +commit 945263a89c3adee61f95d4211cf13b254ad6d51f +Author: Martin Pitt <martinpitt@gnome.org> +Date: Fri Nov 30 14:17:18 2012 +0100 + + Re-support calling GLib.io_add_watch with an fd or Python file + + This does not strictly adhere to the GLib API, but it's very + convenient and + unlike the other modes, does not change the number or order of + arguments. So + let's keep support for this and drop the deprecation warning. + + gi/overrides/GLib.py | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +commit 263b9f97e748746e1d26847a82a4d6e53a42798a +Author: Martin Pitt <martinpitt@gnome.org> +Date: Fri Nov 30 09:04:20 2012 +0100 + + Robustify test_glib.TestGLib.test_io_add_watch_pyfile + + Use a longer timeout to avoid races on slow architectures, and cut + the main + loop as soon as we received all expected events. + + tests/test_glib.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +commit 8e4e822cb273db4eb7e6e40f4739eeebee00798a +Author: Martin Pitt <martinpitt@gnome.org> +Date: Fri Nov 30 08:44:56 2012 +0100 + + test_overrides_gtk: Ignore GVFS warnings from FileChooserDialog + + Do not cause GVFS warnings from Gtk.FileChooserDialog (which may + concern + unavailable monitor backends in the test environment) to fail + the tests. + + tests/test_overrides_gtk.py | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +commit d47283936b4c0b5e8b6ede8886c4badbf6d6e694 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 16:45:49 2012 +0100 + + pygtkcompat: Work around IndexError on large flags + + On 32 bit systems pygtkcompat currently fails with + + File "pygtkcompat/pygtkcompat.py", line 74, in _install_enums + name = flag.value_names[-1].replace(modname + '_', '') + IndexError: cannot fit 'int' into an index-sized integer + + on 32 bit systems as some flags in Gdk are too large to fit into a + 32 bit + "long". Work around this crash until this gets fixed properly + (marked as + FIXME). + + pygtkcompat/pygtkcompat.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +commit 3fa31b1a7936c556e76bd8a42030567c6a867e0d +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 14:11:29 2012 +0100 + + Fix pyg_value_from_pyobject() range check for uint + + We cannot use PYGLIB_PyLong_AsLong() for the range check, as on 32 + bit machines + this overflows large uints. Use PyLong_AsLongLong() separately to + check for + negative values, and PyLong_AsUnsignedLong() for the actual + conversion. + + gi/_gobject/pygtype.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +commit 05d767a602571805e80099f1db47ad4164575c53 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 13:30:56 2012 +0100 + + Fix tests to work with g-i 1.34.2 + + Do not try to call GIMarshallingTests API which isn't present + when running + against g-i 1.34.2. This can be dropped when the g-i dependency gets + bumped to + 1.35.x. + + tests/test_gi.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit a107c928ef85b4e3b9075a408774b74879586029 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 13:13:14 2012 +0100 + + Fix wrong refcount for GVariant property defaults + + Drop the bogus DECREF for the GVariant default argument, as we need + to keep it + around in the class. Otherwise the refcount drops to zero, and + the next + garbage collection run causes segfaults. + + https://bugzilla.gnome.org/show_bug.cgi?id=689267 + + gi/_gobject/gobjectmodule.c | 1 - + 1 file changed, 1 deletion(-) + +commit 9b7dd1318cf540d5f8d03655da03534ed72707ec +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 11:44:22 2012 +0100 + + test_gi: Fix TestFilename failure under C locale + + tests/test_gi.py | 1 + + 1 file changed, 1 insertion(+) + +commit 37ab227555ba8628b4fa99aa286bd046208745ed +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 11:16:26 2012 +0100 + + Fix array arguments on 32 bit + + In _pygi_argument_from_object() we never put the actual element + GType into the + constructed array. The array contains GIArguments, or bytes in the + case of + passing a string as an array. + + This happened to work on 64 bit machines where GIArgument and char* + have the + same size, but not on 32 bit machines + (test_gi.TestPropertiesObject.test_strv + fails there). + + gi/pygi-argument.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 7bd852fc82f92dac8723e18b61a56ed1b1a1b81c +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 10:20:27 2012 +0100 + + test_gi: Disable failing check in test_module_name() + + When calling this under some conditions, such as + + TEST_NAMES='test_thread test_gi.TestOverrides' + + then the module name of GObject.InitiallyUnowned comes out as + "importlib._bootstrap" instead of "gi.repository.GObject". To be + investigated. + Add a couple of other tests to ensure that it is not broken in + general. + + tests/test_gi.py | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +commit 94a6cc93a104b22dcee2ac73cae36b83a4b5d9c1 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 09:40:32 2012 +0100 + + test_gdbus: Drop failure if timeout=0 works differently + + In some test environments we do not actually get a timeout exceptions + with + timeout=0, but a different error message. So only ensure that we + get the right + kind of error. + + tests/test_gdbus.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit c3b2f5fee573aa03a8a9563efbbbc1bc4fa25da7 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Thu Nov 29 09:29:05 2012 +0100 + + test_glib: Drop some assumptions about XDG dirs + + Some directories do not exist in minimal test environments, and this + is not + important for testing that calling these GLib functions works. + + tests/test_glib.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit e45c690bc83b6d513887649de88965a9752e316d +Author: Martin Pitt <martinpitt@gnome.org> +Date: Wed Nov 28 12:20:31 2012 +0100 + + Add backwards compatible API for GLib.unix_signal_add_full() + + This was renamed to GLib.unix_signal_add() in + http://git.gnome.org/browse/glib/commit/?id=fca30c3e165 + + Provide a backwards compatible shim with a deprecation message. + + gi/overrides/GLib.py | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 00b9ea32d766ae486249f402d9dee511fd9f53a9 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Nov 26 08:11:36 2012 +0100 + + Drop MININT64/MAXUINT64 workaround + + g-i 1.34.2 properly handles 64 bit constants now, so bug 685022 has + been fixed + properly now. Drop the workaround in the overrides to manually + set these + constants. + + gi/overrides/GLib.py | 7 ------- + 1 file changed, 7 deletions(-) + +commit d16604f64d25d18409270d7537fc993113b65c19 +Author: Simonas Kazlauskas <simonas@kazlauskas.me> +Date: Fri Nov 23 19:57:56 2012 +0200 + + Fix maximum and minimum ranges of TYPE_(U)INT64 properties + + In corner case where properties use values 2 ** 62 < ±x < 2 ** 63 for + TYPE_INT64 and 2 ** 63 < x < 2 ** 64 for TYPE_UINT64 they will raise + warnings even tough values are valid. + + https://bugzilla.gnome.org/show_bug.cgi?id=688949 + + gi/_gobject/propertyhelper.py | 6 +++--- + tests/test_properties.py | 11 ++++------- + 2 files changed, 7 insertions(+), 10 deletions(-) + +commit 93e9e309d8ba54884881cfca203e8bc355c2727e +Author: Martin Pitt <martinpitt@gnome.org> +Date: Wed Nov 21 12:58:07 2012 +0100 + + Test virtual methods with in and out arguments + + ... and both caller and callee out argument allocation. + + This came up in https://bugzilla.gnome.org/show_bug.cgi?id=688783 + + tests/test_gi.py | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +commit 25a9cfb043448efbab9168ef66f852cc34b9909b +Author: Martin Pitt <martinpitt@gnome.org> +Date: Tue Nov 20 07:00:44 2012 +0100 + + Ship pygi-convert.sh in tarballs + + https://bugzilla.gnome.org/show_bug.cgi?id=688697 + + Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +commit 4a8d31e6f56a3f1360bdb880ffd9a6eb139c02d8 +Author: Martin Pitt <martinpitt@gnome.org> +Date: Mon Nov 19 15:25:38 2012 +0100 + + Post-release version bump to 3.7.3 + + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + commit d0ed62afbc4cada0bf6abc4f8754e5a8d73036e4 Author: Martin Pitt <martinpitt@gnome.org> Date: Mon Nov 19 15:13:28 2012 +0100 diff --git a/Makefile.am b/Makefile.am index eccb79a..f317f84 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,7 @@ EXTRA_DIST = \ pygobject-$(PLATFORM_VERSION).pc.in \ PKG-INFO \ PKG-INFO.in \ + pygi-convert.sh \ m4/as-ac-expand.m4 \ m4/jhflags.m4 \ m4/python.m4 diff --git a/Makefile.in b/Makefile.in index fc397cd..fc44c8d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -346,6 +346,7 @@ EXTRA_DIST = \ pygobject-$(PLATFORM_VERSION).pc.in \ PKG-INFO \ PKG-INFO.in \ + pygi-convert.sh \ m4/as-ac-expand.m4 \ m4/jhflags.m4 \ m4/python.m4 @@ -1,3 +1,22 @@ +3.7.3 17-Dec-2012 + - Add support for caller-allocated GArray out arguments (Martin Pitt) + (#690041) + - [API add] Re-support calling GLib.io_add_watch with an fd or Python + file (Martin Pitt) + - pygtkcompat: Work around IndexError on large flags (Martin Pitt) + - Fix pyg_value_from_pyobject() range check for uint (Martin Pitt) + - Fix tests to work with g-i 1.34.2 (Martin Pitt) + - Fix wrong refcount for GVariant property defaults (Martin Pitt) + (#689267) + - Fix array arguments on 32 bit architectures (Martin Pitt) + - Add backwards compatible API for GLib.unix_signal_add_full() + (Martin Pitt) + - Drop MININT64/MAXUINT64 workaround, current g-i gets this right now + (Martin Pitt) + - Fix maximum and minimum ranges of TYPE_(U)INT64 properties + (Simonas Kazlauskas) (#688949) + - Ship pygi-convert.sh in tarballs (Martin Pitt) (#688697) + 3.7.2 19-Nov-2012 - [API change] Drop almost all static GLib bindings and replace them with proper introspection. This gets rid of several cases where the @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 3.7.2 +Version: 3.7.3 Summary: Python bindings for GObject Home-page: http://www.pygtk.org/ Author: James Henstridge @@ -8,7 +8,7 @@ Author-email: james@daa.com.au Maintainer: Johan Dahlin Maintainer-email: johan@gnome.org License: GNU LGPL -Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.7/pygobject-3.7.2.tar.gz +Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/3.7/pygobject-3.7.3.tar.gz Description: Python bindings for GLib and GObject Platform: POSIX, Windows Classifier: Development Status :: 5 - Production/Stable @@ -20,539 +20,6 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) -# Configure paths for GLIB -# Owen Taylor 1997-2001 - -dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) -dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject, -dnl gthread, or gio is specified in MODULES, pass to pkg-config -dnl -AC_DEFUN([AM_PATH_GLIB_2_0], -[dnl -dnl Get the cflags and libraries from pkg-config -dnl -AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program], - , enable_glibtest=yes) - - pkg_config_args=glib-2.0 - for module in . $4 - do - case "$module" in - gmodule) - pkg_config_args="$pkg_config_args gmodule-2.0" - ;; - gmodule-no-export) - pkg_config_args="$pkg_config_args gmodule-no-export-2.0" - ;; - gobject) - pkg_config_args="$pkg_config_args gobject-2.0" - ;; - gthread) - pkg_config_args="$pkg_config_args gthread-2.0" - ;; - gio*) - pkg_config_args="$pkg_config_args $module-2.0" - ;; - esac - done - - PKG_PROG_PKG_CONFIG([0.16]) - - no_glib="" - - if test "x$PKG_CONFIG" = x ; then - no_glib=yes - PKG_CONFIG=no - fi - - min_glib_version=ifelse([$1], ,2.0.0,$1) - AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) - - if test x$PKG_CONFIG != xno ; then - ## don't try to run the test against uninstalled libtool libs - if $PKG_CONFIG --uninstalled $pkg_config_args; then - echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" - enable_glibtest=no - fi - - if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then - : - else - no_glib=yes - fi - fi - - if test x"$no_glib" = x ; then - GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` - GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` - GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` - GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable=glib_compile_resources gio-2.0` - - GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` - GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` - glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x$enable_glibtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $GLIB_CFLAGS" - LIBS="$GLIB_LIBS $LIBS" -dnl -dnl Now check if the installed GLIB is sufficiently new. (Also sanity -dnl checks the results of pkg-config to some extent) -dnl - rm -f conf.glibtest - AC_TRY_RUN([ -#include <glib.h> -#include <stdio.h> -#include <stdlib.h> - -int -main () -{ - unsigned int major, minor, micro; - char *tmp_version; - - fclose (fopen ("conf.glibtest", "w")); - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = g_strdup("$min_glib_version"); - if (sscanf(tmp_version, "%u.%u.%u", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_glib_version"); - exit(1); - } - - if ((glib_major_version != $glib_config_major_version) || - (glib_minor_version != $glib_config_minor_version) || - (glib_micro_version != $glib_config_micro_version)) - { - printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", - $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, - glib_major_version, glib_minor_version, glib_micro_version); - printf ("*** was found! If pkg-config was correct, then it is best\n"); - printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); - printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); - printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); - printf("*** required on your system.\n"); - printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); - printf("*** to point to the correct configuration files\n"); - } - else if ((glib_major_version != GLIB_MAJOR_VERSION) || - (glib_minor_version != GLIB_MINOR_VERSION) || - (glib_micro_version != GLIB_MICRO_VERSION)) - { - printf("*** GLIB header files (version %d.%d.%d) do not match\n", - GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); - printf("*** library (version %d.%d.%d)\n", - glib_major_version, glib_minor_version, glib_micro_version); - } - else - { - if ((glib_major_version > major) || - ((glib_major_version == major) && (glib_minor_version > minor)) || - ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n", - glib_major_version, glib_minor_version, glib_micro_version); - printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n", - major, minor, micro); - printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); - printf("***\n"); - printf("*** If you have already installed a sufficiently new version, this error\n"); - printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); - printf("*** being found. The easiest way to fix this is to remove the old version\n"); - printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); - printf("*** correct copy of pkg-config. (In this case, you will have to\n"); - printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); - printf("*** so that the correct libraries are found at run-time))\n"); - } - } - return 1; -} -],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_glib" = x ; then - AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - if test "$PKG_CONFIG" = "no" ; then - echo "*** A new enough version of pkg-config was not found." - echo "*** See http://www.freedesktop.org/software/pkgconfig/" - else - if test -f conf.glibtest ; then - : - else - echo "*** Could not run GLIB test program, checking why..." - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $GLIB_CFLAGS" - LIBS="$LIBS $GLIB_LIBS" - AC_TRY_LINK([ -#include <glib.h> -#include <stdio.h> -], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding GLIB or finding the wrong" - echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means GLIB is incorrectly installed."]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - GLIB_CFLAGS="" - GLIB_LIBS="" - GLIB_GENMARSHAL="" - GOBJECT_QUERY="" - GLIB_MKENUMS="" - GLIB_COMPILE_RESOURCES="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) - AC_SUBST(GLIB_GENMARSHAL) - AC_SUBST(GOBJECT_QUERY) - AC_SUBST(GLIB_MKENUMS) - AC_SUBST(GLIB_COMPILE_RESOURCES) - rm -f conf.glibtest -]) - -dnl GNOME_CODE_COVERAGE -dnl -dnl Defines CODE_COVERAGE_CFLAGS and CODE_COVERAGE_LDFLAGS which should be -dnl included in the CFLAGS and LIBS/LDFLAGS variables of every build target -dnl (program or library) which should be built with code coverage support. -dnl Also defines GNOME_CODE_COVERAGE_RULES which should be substituted in your -dnl Makefile; and $enable_code_coverage which can be used in subsequent -dnl configure output. -dnl -dnl Note that all optimisation flags in CFLAGS must be disabled when code -dnl coverage is enabled. -dnl -dnl Derived from Makefile.decl in GLib, originally licenced under LGPLv2.1+. -dnl This file is licenced under GPLv3. For the full gnome-common licence -dnl (GPLv3), see the COPYING file. -dnl -dnl Usage example: -dnl configure.ac: -dnl GNOME_CODE_COVERAGE -dnl -dnl Makefile.am: -dnl @GNOME_CODE_COVERAGE_RULES@ -dnl my_program_LIBS = … $(CODE_COVERAGE_LDFLAGS) … -dnl my_program_CFLAGS = … $(CODE_COVERAGE_CFLAGS) … -dnl -dnl This results in a “check-code-coverage” rule being added to any Makefile.am -dnl which includes “@GNOME_CODE_COVERAGE_RULES@” (assuming the module has been -dnl configured with --enable-code-coverage). Running `make check-code-coverage` -dnl in that directory will run the module’s test suite (`make check`) and build -dnl a code coverage report detailing the code which was touched, then print the -dnl URI for the report. - -AC_DEFUN([GNOME_CODE_COVERAGE],[ - dnl Check for --enable-code-coverage - AC_MSG_CHECKING([whether to build with code coverage support]) - AC_ARG_ENABLE([code-coverage], AS_HELP_STRING([--enable-code-coverage], [Whether to enable code coverage support]),, enable_code_coverage=no) - AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes]) - AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) - AC_MSG_RESULT($enable_code_coverage) - - AS_IF([ test "$enable_code_coverage" = "yes" ], [ - dnl Check if gcc is being used - AS_IF([ test "$GCC" = "no" ], [ - AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) - ]) - - # List of supported lcov versions. - lcov_version_list="1.6 1.7 1.8 1.9" - - AC_CHECK_PROG([LCOV], [lcov], [lcov]) - AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) - - AS_IF([ test "$LCOV" ], [ - AC_CACHE_CHECK([for lcov version], gnome_cv_lcov_version, [ - gnome_cv_lcov_version=invalid - lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` - for lcov_check_version in $lcov_version_list; do - if test "$lcov_version" = "$lcov_check_version"; then - gnome_cv_lcov_version="$lcov_check_version (ok)" - fi - done - ]) - ], [ - lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" - AC_MSG_ERROR([$lcov_msg]) - ]) - - case $gnome_cv_lcov_version in - ""|invalid[)] - lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." - AC_MSG_ERROR([$lcov_msg]) - LCOV="exit 0;" - ;; - esac - - AS_IF([ test -z "$GENHTML" ], [ - AC_MSG_ERROR([Could not find genhtml from the lcov package]) - ]) - - dnl Build the code coverage flags - CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" - CODE_COVERAGE_LDFLAGS="-lgcov" - - AC_SUBST([CODE_COVERAGE_CFLAGS]) - AC_SUBST([CODE_COVERAGE_LDFLAGS]) - ]) - -GNOME_CODE_COVERAGE_RULES=' -# Code coverage -# -# Optional: -# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. -# (Default: $(top_builddir)) -# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated -# by lcov for code coverage. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) -# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage -# reports to be created. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) -# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the lcov instance. -# (Default: empty) -# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml -# instance. (Default: empty) -# -# The generated report will be titled using the $(PACKAGE_NAME) and -# $(PACKAGE_VERSION). In order to add the current git hash to the title, -# use the git-version-gen script, available online. - -# Optional variables -CODE_COVERAGE_DIRECTORY ?= $(top_builddir) -CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info -CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage -CODE_COVERAGE_LCOV_OPTIONS ?= -CODE_COVERAGE_GENHTML_OPTIONS ?= - -# Use recursive makes in order to ignore errors during check -check-code-coverage: -ifdef CODE_COVERAGE_ENABLED - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) code-coverage-capture -else - @echo "Need to reconfigure with --enable-code-coverage" -endif - -# Capture code coverage data -code-coverage-capture: code-coverage-capture-hook -ifdef CODE_COVERAGE_ENABLED - $(LCOV) --directory $(CODE_COVERAGE_DIRECTORY) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_OPTIONS) - $(LCOV) --directory $(CODE_COVERAGE_DIRECTORY) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" - -rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp - LANG=C $(GENHTML) --prefix $(CODE_COVERAGE_DIRECTORY) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) - @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" -else - @echo "Need to reconfigure with --enable-code-coverage" -endif - -# Hook rule executed before code-coverage-capture, overridable by the user -code-coverage-capture-hook: - -clean: code-coverage-clean -code-coverage-clean: - -$(LCOV) --directory $(top_builddir) -z - -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -find . -name "*.gcda" -o -name "*.gcov" -delete - -GITIGNOREFILES ?= -GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -DISTCHECK_CONFIGURE_FLAGS ?= -DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage - -.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean -' - - AC_SUBST([GNOME_CODE_COVERAGE_RULES]) - m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([GNOME_CODE_COVERAGE_RULES])]) -]) - -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) -m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) -AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) -AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_default([$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$$1"; then - pkg_cv_[]$1="$$1" - elif test -n "$PKG_CONFIG"; then - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes ], - [pkg_failed=yes]) - else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - m4_default([$4], [AC_MSG_ERROR( -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT])[]dnl - ]) -elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) - m4_default([$4], [AC_MSG_FAILURE( -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl - ]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - $3 -fi[]dnl -])# PKG_CHECK_MODULES - # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # @@ -1851,6 +1318,539 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +dnl GNOME_CODE_COVERAGE +dnl +dnl Defines CODE_COVERAGE_CFLAGS and CODE_COVERAGE_LDFLAGS which should be +dnl included in the CFLAGS and LIBS/LDFLAGS variables of every build target +dnl (program or library) which should be built with code coverage support. +dnl Also defines GNOME_CODE_COVERAGE_RULES which should be substituted in your +dnl Makefile; and $enable_code_coverage which can be used in subsequent +dnl configure output. +dnl +dnl Note that all optimisation flags in CFLAGS must be disabled when code +dnl coverage is enabled. +dnl +dnl Derived from Makefile.decl in GLib, originally licenced under LGPLv2.1+. +dnl This file is licenced under GPLv3. For the full gnome-common licence +dnl (GPLv3), see the COPYING file. +dnl +dnl Usage example: +dnl configure.ac: +dnl GNOME_CODE_COVERAGE +dnl +dnl Makefile.am: +dnl @GNOME_CODE_COVERAGE_RULES@ +dnl my_program_LIBS = … $(CODE_COVERAGE_LDFLAGS) … +dnl my_program_CFLAGS = … $(CODE_COVERAGE_CFLAGS) … +dnl +dnl This results in a “check-code-coverage” rule being added to any Makefile.am +dnl which includes “@GNOME_CODE_COVERAGE_RULES@” (assuming the module has been +dnl configured with --enable-code-coverage). Running `make check-code-coverage` +dnl in that directory will run the module’s test suite (`make check`) and build +dnl a code coverage report detailing the code which was touched, then print the +dnl URI for the report. + +AC_DEFUN([GNOME_CODE_COVERAGE],[ + dnl Check for --enable-code-coverage + AC_MSG_CHECKING([whether to build with code coverage support]) + AC_ARG_ENABLE([code-coverage], AS_HELP_STRING([--enable-code-coverage], [Whether to enable code coverage support]),, enable_code_coverage=no) + AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes]) + AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) + AC_MSG_RESULT($enable_code_coverage) + + AS_IF([ test "$enable_code_coverage" = "yes" ], [ + dnl Check if gcc is being used + AS_IF([ test "$GCC" = "no" ], [ + AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) + ]) + + # List of supported lcov versions. + lcov_version_list="1.6 1.7 1.8 1.9" + + AC_CHECK_PROG([LCOV], [lcov], [lcov]) + AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) + + AS_IF([ test "$LCOV" ], [ + AC_CACHE_CHECK([for lcov version], gnome_cv_lcov_version, [ + gnome_cv_lcov_version=invalid + lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` + for lcov_check_version in $lcov_version_list; do + if test "$lcov_version" = "$lcov_check_version"; then + gnome_cv_lcov_version="$lcov_check_version (ok)" + fi + done + ]) + ], [ + lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" + AC_MSG_ERROR([$lcov_msg]) + ]) + + case $gnome_cv_lcov_version in + ""|invalid[)] + lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." + AC_MSG_ERROR([$lcov_msg]) + LCOV="exit 0;" + ;; + esac + + AS_IF([ test -z "$GENHTML" ], [ + AC_MSG_ERROR([Could not find genhtml from the lcov package]) + ]) + + dnl Build the code coverage flags + CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" + CODE_COVERAGE_LDFLAGS="-lgcov" + + AC_SUBST([CODE_COVERAGE_CFLAGS]) + AC_SUBST([CODE_COVERAGE_LDFLAGS]) + ]) + +GNOME_CODE_COVERAGE_RULES=' +# Code coverage +# +# Optional: +# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. +# (Default: $(top_builddir)) +# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated +# by lcov for code coverage. (Default: +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) +# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage +# reports to be created. (Default: +# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) +# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the lcov instance. +# (Default: empty) +# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml +# instance. (Default: empty) +# +# The generated report will be titled using the $(PACKAGE_NAME) and +# $(PACKAGE_VERSION). In order to add the current git hash to the title, +# use the git-version-gen script, available online. + +# Optional variables +CODE_COVERAGE_DIRECTORY ?= $(top_builddir) +CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info +CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage +CODE_COVERAGE_LCOV_OPTIONS ?= +CODE_COVERAGE_GENHTML_OPTIONS ?= + +# Use recursive makes in order to ignore errors during check +check-code-coverage: +ifdef CODE_COVERAGE_ENABLED + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) code-coverage-capture +else + @echo "Need to reconfigure with --enable-code-coverage" +endif + +# Capture code coverage data +code-coverage-capture: code-coverage-capture-hook +ifdef CODE_COVERAGE_ENABLED + $(LCOV) --directory $(CODE_COVERAGE_DIRECTORY) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_OPTIONS) + $(LCOV) --directory $(CODE_COVERAGE_DIRECTORY) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" + -rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp + LANG=C $(GENHTML) --prefix $(CODE_COVERAGE_DIRECTORY) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) + @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" +else + @echo "Need to reconfigure with --enable-code-coverage" +endif + +# Hook rule executed before code-coverage-capture, overridable by the user +code-coverage-capture-hook: + +clean: code-coverage-clean +code-coverage-clean: + -$(LCOV) --directory $(top_builddir) -z + -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) + -find . -name "*.gcda" -o -name "*.gcov" -delete + +GITIGNOREFILES ?= +GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) + +DISTCHECK_CONFIGURE_FLAGS ?= +DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage + +.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean +' + + AC_SUBST([GNOME_CODE_COVERAGE_RULES]) + m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([GNOME_CODE_COVERAGE_RULES])]) +]) + +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])# PKG_CHECK_MODULES + +# Configure paths for GLIB +# Owen Taylor 1997-2001 + +dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject, +dnl gthread, or gio is specified in MODULES, pass to pkg-config +dnl +AC_DEFUN([AM_PATH_GLIB_2_0], +[dnl +dnl Get the cflags and libraries from pkg-config +dnl +AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program], + , enable_glibtest=yes) + + pkg_config_args=glib-2.0 + for module in . $4 + do + case "$module" in + gmodule) + pkg_config_args="$pkg_config_args gmodule-2.0" + ;; + gmodule-no-export) + pkg_config_args="$pkg_config_args gmodule-no-export-2.0" + ;; + gobject) + pkg_config_args="$pkg_config_args gobject-2.0" + ;; + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + gio*) + pkg_config_args="$pkg_config_args $module-2.0" + ;; + esac + done + + PKG_PROG_PKG_CONFIG([0.16]) + + no_glib="" + + if test "x$PKG_CONFIG" = x ; then + no_glib=yes + PKG_CONFIG=no + fi + + min_glib_version=ifelse([$1], ,2.0.0,$1) + AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) + + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" + enable_glibtest=no + fi + + if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then + : + else + no_glib=yes + fi + fi + + if test x"$no_glib" = x ; then + GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` + GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable=glib_compile_resources gio-2.0` + + GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` + GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` + glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" +dnl +dnl Now check if the installed GLIB is sufficiently new. (Also sanity +dnl checks the results of pkg-config to some extent) +dnl + rm -f conf.glibtest + AC_TRY_RUN([ +#include <glib.h> +#include <stdio.h> +#include <stdlib.h> + +int +main () +{ + unsigned int major, minor, micro; + char *tmp_version; + + fclose (fopen ("conf.glibtest", "w")); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%u.%u.%u", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%u.%u.%u) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %u.%u.%u. The latest version of\n", + major, minor, micro); + printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://www.freedesktop.org/software/pkgconfig/" + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + AC_TRY_LINK([ +#include <glib.h> +#include <stdio.h> +], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB is incorrectly installed."]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + GLIB_GENMARSHAL="" + GOBJECT_QUERY="" + GLIB_MKENUMS="" + GLIB_COMPILE_RESOURCES="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + AC_SUBST(GLIB_GENMARSHAL) + AC_SUBST(GOBJECT_QUERY) + AC_SUBST(GLIB_MKENUMS) + AC_SUBST(GLIB_COMPILE_RESOURCES) + rm -f conf.glibtest +]) + m4_include([m4/as-ac-expand.m4]) m4_include([m4/jhflags.m4]) m4_include([m4/libtool.m4]) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pygobject 3.7.2. +# Generated by GNU Autoconf 2.69 for pygobject 3.7.3. # # Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='3.7.2' -PACKAGE_STRING='pygobject 3.7.2' +PACKAGE_VERSION='3.7.3' +PACKAGE_STRING='pygobject 3.7.3' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject' PACKAGE_URL='https://live.gnome.org/PyGObject/' @@ -1391,7 +1391,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pygobject 3.7.2 to adapt to many kinds of systems. +\`configure' configures pygobject 3.7.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1461,7 +1461,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pygobject 3.7.2:";; + short | recursive ) echo "Configuration of pygobject 3.7.3:";; esac cat <<\_ACEOF @@ -1593,7 +1593,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 3.7.2 +pygobject configure 3.7.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1871,7 +1871,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pygobject $as_me 3.7.2, which was +It was created by pygobject $as_me 3.7.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2235,9 +2235,9 @@ $as_echo "#define PYGOBJECT_MINOR_VERSION 7" >>confdefs.h PYGOBJECT_MINOR_VERSION=7 -$as_echo "#define PYGOBJECT_MICRO_VERSION 2" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 3" >>confdefs.h -PYGOBJECT_MICRO_VERSION=2 +PYGOBJECT_MICRO_VERSION=3 ac_config_headers="$ac_config_headers config.h" @@ -2748,7 +2748,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='3.7.2' + VERSION='3.7.3' cat >>confdefs.h <<_ACEOF @@ -4699,7 +4699,8 @@ else ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else @@ -6230,7 +6231,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -15957,7 +15965,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pygobject $as_me 3.7.2, which was +This file was extended by pygobject $as_me 3.7.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16024,7 +16032,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -pygobject config.status 3.7.2 +pygobject config.status 3.7.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a87998e..dd5e078 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ m4_define(python3_min_ver, 3.1) dnl the pygobject version number m4_define(pygobject_major_version, 3) m4_define(pygobject_minor_version, 7) -m4_define(pygobject_micro_version, 2) +m4_define(pygobject_micro_version, 3) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... diff --git a/gi/_gobject/gobjectmodule.c b/gi/_gobject/gobjectmodule.c index 479eb93..304a041 100644 --- a/gi/_gobject/gobjectmodule.c +++ b/gi/_gobject/gobjectmodule.c @@ -648,7 +648,6 @@ create_property (const gchar *prop_name, return NULL; if (pydefault != Py_None) default_value = pyg_boxed_get (pydefault, GVariant); - Py_DECREF(pydefault); pspec = g_param_spec_variant (prop_name, nick, blurb, G_VARIANT_TYPE_ANY, default_value, flags); } break; diff --git a/gi/_gobject/propertyhelper.py b/gi/_gobject/propertyhelper.py index a951ff3..a038f1b 100644 --- a/gi/_gobject/propertyhelper.py +++ b/gi/_gobject/propertyhelper.py @@ -93,14 +93,14 @@ class Property(object): TYPE_DOUBLE: -G_MAXDOUBLE, TYPE_INT: G_MININT, TYPE_LONG: G_MINLONG, - TYPE_INT64: -2 ** 62 - 1, + TYPE_INT64: -2 ** 63, } _max_value_lookup = { TYPE_UINT: G_MAXUINT, TYPE_ULONG: G_MAXULONG, - TYPE_INT64: 2 ** 62 - 1, - TYPE_UINT64: 2 ** 63 - 1, + TYPE_INT64: 2 ** 63 - 1, + TYPE_UINT64: 2 ** 64 - 1, TYPE_FLOAT: G_MAXFLOAT, TYPE_DOUBLE: G_MAXDOUBLE, TYPE_INT: G_MAXINT, diff --git a/gi/_gobject/pygtype.c b/gi/_gobject/pygtype.c index adc8c12..79c8387 100644 --- a/gi/_gobject/pygtype.c +++ b/gi/_gobject/pygtype.c @@ -811,11 +811,15 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) case G_TYPE_UINT: { if (PYGLIB_PyLong_Check(obj)) { - glong val; + guint val; - val = PYGLIB_PyLong_AsLong(obj); - if (val >= 0 && val <= G_MAXUINT) - g_value_set_uint(value, (guint)val); + /* check that number is not negative */ + if (PyLong_AsLongLong(obj) < 0) + return -1; + + val = PyLong_AsUnsignedLong(obj); + if (val <= G_MAXUINT) + g_value_set_uint(value, val); else return -1; } else { diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py index ed63679..6ae5dba 100644 --- a/gi/overrides/GLib.py +++ b/gi/overrides/GLib.py @@ -490,8 +490,12 @@ class MainLoop(GLib.MainLoop): loop.quit() loop._quit_by_sigint = True - self._signal_source = GLib.unix_signal_add_full( - GLib.PRIORITY_DEFAULT, signal.SIGINT, _handler, self) + # compatibility shim, keep around until we depend on glib 2.36 + if hasattr(GLib, 'unix_signal_add'): + fn = GLib.unix_signal_add + else: + fn = GLib.unix_signal_add_full + self._signal_source = fn(GLib.PRIORITY_DEFAULT, signal.SIGINT, _handler, self) def __del__(self): GLib.source_remove(self._signal_source) @@ -639,9 +643,10 @@ __all__.append('timeout_add_seconds') # The real GLib API is io_add_watch(IOChannel, priority, condition, callback, -# user_data). This needs to take into account several deprecated APIs: +# user_data). This needs to take into account several historical APIs: # - calling with an fd as first argument -# - calling with a Python file object as first argument +# - calling with a Python file object as first argument (we keep this one as +# it's really convenient and does not change the number of arguments) # - calling without a priority as second argument # and the usual "call without or multiple user_data", in which case the # callback gets the same user data arguments. @@ -673,14 +678,10 @@ def io_add_watch(channel, priority_, condition, *cb_and_user_data, **kwargs): # backwards compatibility: Allow calling with fd if isinstance(channel, int): - warnings.warn('Calling io_add_watch with a file descriptor is deprecated; call it with a GLib.IOChannel object', - PyGIDeprecationWarning) func_fdtransform = lambda _, cond, data: func(channel, cond, data) real_channel = GLib.IOChannel.unix_new(channel) elif hasattr(channel, 'fileno'): # backwards compatibility: Allow calling with Python file - warnings.warn('Calling io_add_watch with a file object is deprecated; call it with a GLib.IOChannel object', - PyGIDeprecationWarning) func_fdtransform = lambda _, cond, data: func(channel, cond, data) real_channel = GLib.IOChannel.unix_new(channel.fileno()) else: @@ -837,15 +838,18 @@ def filename_from_utf8(utf8string, len=-1): __all__.append('filename_from_utf8') +# backwards compatible API for renamed function +if not hasattr(GLib, 'unix_signal_add_full'): + def add_full_compat(*args): + warnings.warn('GLib.unix_signal_add_full() was renamed to GLib.unix_signal_add()', + PyGIDeprecationWarning) + return GLib.unix_signal_add(*args) + + GLib.unix_signal_add_full = add_full_compat + + # obsolete constants for backwards compatibility glib_version = (GLib.MAJOR_VERSION, GLib.MINOR_VERSION, GLib.MICRO_VERSION) __all__.append('glib_version') pyglib_version = version_info __all__.append('pyglib_version') - -# work around wrong constants in GLib GIR, see -# https://bugzilla.gnome.org/show_bug.cgi?id=685022 -MININT64 = -9223372036854775808 -MAXUINT64 = 18446744073709551615 -__all__.append('MININT64') -__all__.append('MAXUINT64') diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 61453e0..4e3c464 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -1146,7 +1146,11 @@ _pygi_argument_from_object (PyObject *object, is_zero_terminated = g_type_info_is_zero_terminated (type_info); item_type_info = g_type_info_get_param_type (type_info, 0); - item_size = _pygi_g_type_info_size (item_type_info); + /* we handle arrays that are really strings specially, see below */ + if (g_type_info_get_tag (item_type_info) == GI_TYPE_TAG_UINT8) + item_size = 1; + else + item_size = sizeof (GIArgument); array = g_array_sized_new (is_zero_terminated, FALSE, item_size, length); if (array == NULL) { diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c index 21dd58f..2a44c02 100644 --- a/gi/pygi-cache.c +++ b/gi/pygi-cache.c @@ -1370,7 +1370,7 @@ _args_cache_generate (GICallableInfo *callable_info, type_info = g_arg_info_get_type (arg_info); type_tag = g_type_info_get_tag (type_info); - if (type_tag == GI_TYPE_TAG_INTERFACE) + if (type_tag == GI_TYPE_TAG_INTERFACE || type_tag == GI_TYPE_TAG_ARRAY) is_caller_allocates = g_arg_info_is_caller_allocates (arg_info); /* must be an child arg filled in by its owner diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index c0f7179..195a830 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -361,33 +361,38 @@ static gboolean _caller_alloc (PyGIInvokeState *state, gssize arg_count, gssize out_count) { - PyGIInterfaceCache *iface_cache; - - g_assert (arg_cache->type_tag == GI_TYPE_TAG_INTERFACE); - - iface_cache = (PyGIInterfaceCache *)arg_cache; - - state->out_args[out_count].v_pointer = NULL; - state->args[arg_count] = &state->out_args[out_count]; - if (iface_cache->g_type == G_TYPE_BOXED) { - state->args[arg_count]->v_pointer = - _pygi_boxed_alloc (iface_cache->interface_info, NULL); - } else if (iface_cache->g_type == G_TYPE_VALUE) { - state->args[arg_count]->v_pointer = g_slice_new0 (GValue); - } else if (iface_cache->is_foreign) { - PyObject *foreign_struct = - pygi_struct_foreign_convert_from_g_argument ( - iface_cache->interface_info, - NULL); - - pygi_struct_foreign_convert_to_g_argument (foreign_struct, - iface_cache->interface_info, - GI_TRANSFER_EVERYTHING, - state->args[arg_count]); + if (arg_cache->type_tag == GI_TYPE_TAG_INTERFACE) { + PyGIInterfaceCache *iface_cache = (PyGIInterfaceCache *)arg_cache; + + state->out_args[out_count].v_pointer = NULL; + state->args[arg_count] = &state->out_args[out_count]; + if (iface_cache->g_type == G_TYPE_BOXED) { + state->args[arg_count]->v_pointer = + _pygi_boxed_alloc (iface_cache->interface_info, NULL); + } else if (iface_cache->g_type == G_TYPE_VALUE) { + state->args[arg_count]->v_pointer = g_slice_new0 (GValue); + } else if (iface_cache->is_foreign) { + PyObject *foreign_struct = + pygi_struct_foreign_convert_from_g_argument ( + iface_cache->interface_info, + NULL); + + pygi_struct_foreign_convert_to_g_argument (foreign_struct, + iface_cache->interface_info, + GI_TRANSFER_EVERYTHING, + state->args[arg_count]); + } else { + gssize size = g_struct_info_get_size( + (GIStructInfo *)iface_cache->interface_info); + state->args[arg_count]->v_pointer = g_malloc0 (size); + } + } else if (arg_cache->type_tag == GI_TYPE_TAG_ARRAY) { + PyGISequenceCache *seq_cache = (PyGISequenceCache *)arg_cache; + + state->out_args[out_count].v_pointer = g_array_new (TRUE, TRUE, seq_cache->item_size); + state->args[arg_count] = &state->out_args[out_count]; } else { - gssize size = g_struct_info_get_size( - (GIStructInfo *)iface_cache->interface_info); - state->args[arg_count]->v_pointer = g_malloc0 (size); + return FALSE; } if (state->args[arg_count]->v_pointer == NULL) @@ -70,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.1ubuntu1 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.2ubuntu1 # automake: $automake_version # autoconf: $autoconf_version # @@ -80,7 +80,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.1ubuntu1" +VERSION="2.4.2 Debian-2.4.2-1.2ubuntu1" TIMESTAMP="" package_revision=1.3337 diff --git a/m4/libtool.m4 b/m4/libtool.m4 index 534d1cc..02b4bbe 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1324,7 +1324,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" @@ -1688,7 +1695,8 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else diff --git a/pygi-convert.sh b/pygi-convert.sh new file mode 100755 index 0000000..c5887f8 --- /dev/null +++ b/pygi-convert.sh @@ -0,0 +1,350 @@ +#!/bin/sh + +if [ -n "$1" ]; then + FILES_TO_CONVERT="$@" +else + FILES_TO_CONVERT="$(find . -name '*.py')" +fi + +for f in $FILES_TO_CONVERT; do + perl -i -0 \ + -pe "s/import gconf\n/from gi.repository import GConf\n/g;" \ + -pe "s/gconf\./GConf\./g;" \ + -pe "s/GConf\.client_get_default/GConf.Client.get_default/g;" \ + -pe "s/GConf\.CLIENT_/GConf.ClientPreloadType./g;" \ + -pe "s/GConf\.VALUE_/GConf.ValueType./g;" \ + -pe "s/gconf_client.notify_add\('\/desktop\/sugar\/collaboration\/publish_gadget',/return;gconf_client.notify_add\('\/desktop\/sugar\/collaboration\/publish_gadget',/g;" \ +\ + -pe "s/import pygtk/import gi/g;" \ + -pe "s/pygtk.require\('2.0'\)/gi.require_version\('Gtk', '3.0'\)/g;" \ + -pe "s/import gtk\n/from gi.repository import Gtk\n/g;" \ + -pe "s/(?<!\.)gtk\./Gtk\./g;" \ + -pe "s/Gtk.ACCEL_/Gtk.AccelFlags./g;" \ + -pe "s/Gtk.ARROW_/Gtk.ArrowType./g;" \ + -pe "s/Gtk.ASSISTANT_PAGE_/Gtk.AssistantPageType./g;" \ + -pe "s/Gtk.BUTTONBOX_/Gtk.ButtonBoxStyle./g;" \ + -pe "s/Gtk.BUTTONS_/Gtk.ButtonsType./g;" \ + -pe "s/Gtk.CELL_RENDERER_MODE_/Gtk.CellRendererMode./g;" \ + -pe "s/Gtk.CELL_RENDERER_FOCUSED/Gtk.CellRendererState.FOCUSED/g;" \ + -pe "s/Gtk.CELL_RENDERER_INSENSITIVE/Gtk.CellRendererState.INSENSITIVE/g;" \ + -pe "s/Gtk.CELL_RENDERER_PRELIT/Gtk.CellRendererState.PRELIT/g;" \ + -pe "s/Gtk.CELL_RENDERER_SORTED/Gtk.CellRendererState.SORTED/g;" \ + -pe "s/Gtk.CELL_RENDERER_SELECTED/Gtk.CellRendererState.SELECTED/g;" \ + -pe "s/Gtk.CORNER_/Gtk.CornerType./g;" \ + -pe "s/Gtk.DIALOG_/Gtk.DialogFlags./g;" \ + -pe "s/Gtk.ENTRY_ICON_/Gtk.EntryIconPosition./g;" \ + -pe "s/Gtk.EXPAND/Gtk.AttachOptions.EXPAND/g;" \ + -pe "s/Gtk.FALSE/False/g;" \ + -pe "s/Gtk.FILE_CHOOSER_ACTION_/Gtk.FileChooserAction./g;" \ + -pe "s/Gtk.FILL/Gtk.AttachOptions.FILL/g;" \ + -pe "s/Gtk.ICON_LOOKUP_/Gtk.IconLookupFlags./g;" \ + -pe "s/Gtk.ICON_SIZE_/Gtk.IconSize./g;" \ + -pe "s/Gtk.IMAGE_/Gtk.ImageType./g;" \ + -pe "s/Gtk.JUSTIFY_/Gtk.Justification./g;" \ + -pe "s/Gtk.MESSAGE_/Gtk.MessageType./g;" \ + -pe "s/Gtk.MOVEMENT_/Gtk.MovementStep./g;" \ + -pe "s/Gtk.ORIENTATION_/Gtk.Orientation./g;" \ + -pe "s/Gtk.POLICY_/Gtk.PolicyType./g;" \ + -pe "s/Gtk.POS_/Gtk.PositionType./g;" \ + -pe "s/Gtk.RELIEF_/Gtk.ReliefStyle./g;" \ + -pe "s/Gtk.RESPONSE_/Gtk.ResponseType./g;" \ + -pe "s/Gtk.SELECTION_/Gtk.SelectionMode./g;" \ + -pe "s/Gtk.SHADOW_/Gtk.ShadowType./g;" \ + -pe "s/Gtk.SHADOW_NONE/Gtk.ShadowType.NONE/g;" \ + -pe "s/Gtk.SHRINK/Gtk.AttachOptions.SHRINK/g;" \ + -pe "s/Gtk.SIZE_GROUP_/Gtk.SizeGroupMode./g;" \ + -pe "s/Gtk.SORT_/Gtk.SortType./g;" \ + -pe "s/Gtk.STATE_/Gtk.StateType./g;" \ + -pe "s/Gtk.TARGET_/Gtk.TargetFlags./g;" \ + -pe "s/Gtk.TEXT_DIR_/Gtk.TextDirection./g;" \ + -pe "s/Gtk.TEXT_SEARCH_/Gtk.TextSearchFlags./g;" \ + -pe "s/Gtk.TEXT_WINDOW_/Gtk.TextWindowType./g;" \ + -pe "s/Gtk.TREE_VIEW_COLUMN_/Gtk.TreeViewColumnSizing./g;" \ + -pe "s/Gtk.TREE_VIEW_DROP_/Gtk.TreeViewDropPosition./g;" \ + -pe "s/Gtk.TRUE/True/g;" \ + -pe "s/Gtk.WINDOW_/Gtk.WindowType./g;" \ + -pe "s/Gtk.DEST_DEFAULT_/Gtk.DestDefaults./g;" \ + -pe "s/Gtk.WIN_POS_/Gtk.WindowPosition./g;" \ + -pe "s/Gtk.WRAP_/Gtk.WrapMode./g;" \ + -pe "s/Gtk.UI_MANAGER_/Gtk.UIManagerItemType./g;" \ + -pe "s/Gtk.accel_map_/Gtk.AccelMap./g;" \ + -pe "s/Gtk.settings_get_/Gtk.Settings.get_/g;" \ + -pe "s/Gtk.icon_theme_get_default/Gtk.IconTheme.get_default/g;" \ + -pe "s/Gtk.image_new_from_stock/Gtk.Image.new_from_stock/g;" \ + -pe "s/Gtk.image_new_from_icon_name/Gtk.Image.new_from_icon_name/g;" \ + -pe "s/Gtk.window_set_default_icon_name/Gtk.Window.set_default_icon_name/g; " \ + -pe "s/Gtk.combo_box_new_text/Gtk.ComboBoxText/g;" \ + -pe "s/Gtk.keysyms./Gdk.KEY_/g;" \ + -pe "s/set_flags\(Gtk.CAN_DEFAULT\)/set_can_default\(True\)/g;" \ + -pe "s/.flags\(\) & Gtk.MAPPED/.get_mapped\(\)/g;" \ + -pe "s/.flags\(\) & Gtk.REALIZED/.get_realized\(\)/g;" \ + -pe "s/\.window\.set_type_hint/.set_type_hint/g;" \ + -pe "s/\.window\.set_skip_taskbar_hint/.set_skip_taskbar_hint/g;" \ + -pe "s/\.window\.set_transient_for/.set_transient_for/g;" \ + -pe "s/Gtk.Alignment\(/Gtk.Alignment.new\(/g;" \ + -pe "#s/Gtk.Window.__init__\(self\)/Gtk.Window.__init__\(Gtk.WindowType.TOPLEVEL\)/g;" \ + -pe "s/\.child([^_A-Za-z])/.get_child\(\)\1/g;" \ +\ + -pe "s/column.pack_start\(([^,\)]*)\)/column.pack_start\(\1, True\)/g;" \ + -pe "s/pack_start\(([^,\)]*)\)/pack_start\(\1, True, True, 0\)/g;" \ + -pe "s/pack_start\(([^,]*), fill=([^,\)]*)\)/pack_start\(\1, True, \2, 0\)/g;" \ + -pe "s/pack_start\(([^,]*), expand=([^,\)]*)\)/pack_start\(\1, \2, True, 0\)/g;" \ + -pe "s/pack_start\(([^,]*),(\s*)padding=([A-Za-z0-9._]*)\)/pack_start\(\1,\2True, True,\2\3\)/g;" \ + -pe "s/column.pack_end\(([^,\)]*)\)/column.pack_end\(\1, True\)/g;" \ + -pe "s/pack_end\(([^,\)]*)\)/pack_end\(\1, True, True, 0\)/g;" \ + -pe "s/pack_end\(([^,]*), fill=([^,\)]*)\)/pack_end\(\1, True, \2, 0\)/g;" \ + -pe "s/pack_end\(([^,]*), expand=([^,\)]*)\)/pack_end\(\1, \2, True, 0\)/g;" \ + -pe "s/pack_end\(([^,]*),(\s*)padding=([A-Za-z0-9._]*)\)/pack_end\(\1,\2True, True,\2\3\)/g;" \ + -pe "#s/Gtk.HBox\(\)/Gtk.HBox\(False, 0\)/g;" \ + -pe "#s/Gtk.VBox\(\)/Gtk.VBox\(False, 0\)/g;" \ + -pe "s/Gtk.Label\s*\(([^,\)]+)\)/Gtk.Label\(label=\1\)/g;" \ + -pe "s/Gtk.AccelLabel\s*\(([^,\)]+)\)/Gtk.AccelLabel\(label=\1\)/g;" \ + -pe "s/Gtk.((?:Accel)?Label)\(label=label=/Gtk.\1\(label=/g;" \ + -pe "s/len\(self._content.get_children\(\)\) > 0/self._content.get_children\(\)/g;" \ + -pe "s/len\(self.menu.get_children\(\)\) > 0/self.menu.get_children\(\)/g;" \ + -pe "s/import gobject\n/from gi.repository import GObject\n/g;" \ + -pe "s/Gtk\..*\.__init__/gobject.GObject.__init__/g;" \ +\ + -pe "s/rsvg.Handle\s*\(data=([^,\)]+)\)/Rsvg.Handle.new_from_data(\1)/g;" \ +\ + -pe "s/from gtk import gdk\n/from gi.repository import Gdk\n/g;" \ + -pe "s/import gtk.gdk as gdk\n/from gi.repository import Gdk\n/g;" \ + -pe "s/Gtk.gdk.x11_/GdkX11.x11_/g;" \ + -pe "s/Gtk.gdk\./Gdk\./g;" \ + -pe "s/(?<!\.)gdk\./Gdk\./g;" \ + -pe "s/Gdk.screen_width/Gdk.Screen.width/g;" \ + -pe "s/Gdk.screen_height/Gdk.Screen.height/g;" \ + -pe "s/Gdk.screen_get_default/Gdk.Screen.get_default/g;" \ + -pe "s/Gdk.display_get_default/Gdk.Display.get_default/g;" \ + -pe "s/screen_, x_, y_, modmask = display.get_pointer\(\)/x_, y_, modmask = display.get_pointer\(None\)/g;" \ + -pe "s/Gdk.WINDOW_TYPE_HINT_/Gdk.WindowTypeHint./g;" \ + -pe "s/Gdk.SHIFT_MASK/Gdk.ModifierType.SHIFT_MASK/g;" \ + -pe "s/Gdk.LOCK_MASK/Gdk.ModifierType.LOCK_MASK/g;" \ + -pe "s/Gdk.CONTROL_MASK/Gdk.ModifierType.CONTROL_MASK/g;" \ + -pe "s/Gdk.MOD1_MASK/Gdk.ModifierType.MOD1_MASK/g;" \ + -pe "s/Gdk.MOD2_MASK/Gdk.ModifierType.MOD2_MASK/g;" \ + -pe "s/Gdk.MOD3_MASK/Gdk.ModifierType.MOD3_MASK/g;" \ + -pe "s/Gdk.MOD4_MASK/Gdk.ModifierType.MOD4_MASK/g;" \ + -pe "s/Gdk.MOD5_MASK/Gdk.ModifierType.MOD5_MASK/g;" \ + -pe "s/Gdk.BUTTON1_MASK/Gdk.ModifierType.BUTTON1_MASK/g;" \ + -pe "s/Gdk.BUTTON2_MASK/Gdk.ModifierType.BUTTON2_MASK/g;" \ + -pe "s/Gdk.BUTTON3_MASK/Gdk.ModifierType.BUTTON3_MASK/g;" \ + -pe "s/Gdk.BUTTON4_MASK/Gdk.ModifierType.BUTTON4_MASK/g;" \ + -pe "s/Gdk.BUTTON5_MASK/Gdk.ModifierType.BUTTON5_MASK/g;" \ + -pe "s/Gdk.RELEASE_MASK/Gdk.ModifierType.RELEASE_MASK/g;" \ + -pe "s/Gdk.MODIFIER_MASK/Gdk.ModifierType.MODIFIER_MASK/g;" \ + -pe "s/Gdk.([A-Z_0-9]*)_MASK/Gdk.EventMask.\1_MASK/g;" \ + -pe "s/Gdk.VISIBILITY_FULLY_OBSCURED/Gdk.VisibilityState.FULLY_OBSCURED/g;" \ + -pe "s/Gdk.NOTIFY_ANCESTOR/Gdk.NotifyType.ANCESTOR/g;" \ + -pe "s/Gdk.NOTIFY_INFERIOR/Gdk.NotifyType.INFERIOR/g;" \ + -pe "s/Gdk.NOTIFY_NONLINEAR_VIRTUAL/Gdk.NotifyType.NONLINEAR_VIRTUAL/g;" \ + -pe "s/Gdk.NOTIFY_NONLINEAR/Gdk.NotifyType.NONLINEAR/g;" \ + -pe "s/Gdk.NOTIFY_UNKNOWN/Gdk.NotifyType.UNKNOWN/g;" \ + -pe "s/Gdk.NOTIFY_VIRTUAL/Gdk.NotifyType.VIRTUAL/g;" \ + -pe "s/Gdk.PROP_MODE_APPEND/Gdk.PropMode.APPEND/g;" \ + -pe "s/Gdk.PROP_MODE_PREPEND/Gdk.PropMode.PREPEND/g;" \ + -pe "s/Gdk.PROP_MODE_REPLACE/Gdk.PropMode.REPLACE/g;" \ + -pe "s/Gdk.BUTTON_PRESS/Gdk.EventType.BUTTON_PRESS/g;" \ + -pe "s/Gdk.ACTION_/Gdk.DragAction./g;" \ + -pe "s/Gdk.GRAB_/Gdk.GrabStatus./g;" \ + -pe "s/Gdk.SCROLL_(DOWN|LEFT|RIGHT|UP)/Gdk.ScrollDirection.\1/g;" \ + -pe "s/Gdk.([A-Z]+_(PTR|CURSOR))/Gdk.CursorType.\1/g;" \ + -pe "s/Gdk.(CROSSHAIR)/Gdk.CursorType.\1/g;" \ + -pe "s/Gdk.(WATCH)/Gdk.CursorType.\1/g;" \ + -pe "s/Gdk.(ARROW)/Gdk.CursorType.\1/g;" \ + -pe "s/Gdk.(CLOCK)/Gdk.CursorType.\1/g;" \ + -pe "s/Gdk.WINDOW_STATE_(ABOVE|BELOW|FOCUSED|FULLSCREEN|ICONIFIED|MAXIMIZED|STICKY|WITHDRAWN)/Gdk.WindowState.\1/g;" \ + -pe "s/Gdk.Cursor\s*\(/Gdk.Cursor.new\(/g;" \ + -pe "s/#Gdk.Rectangle\(([^,\)]*), ([^,\)]*), ([^,\)]*), ([^,\)]*)\)/\1, \2, \3, \4/g;" \ + -pe "s/Gdk.Rectangle//g;" \ + -pe "s/intersection = child_rect.intersect/intersects_, intersection = child_rect.intersect/g;" \ + -pe "s/event.state/event.get_state\(\)/g;" \ +\ + -pe "s/Gdk.pixbuf_/GdkPixbuf.Pixbuf./g;" \ + -pe "s/Gdk.Pixbuf/GdkPixbuf.Pixbuf/g;" \ + -pe "s/Gdk.INTERP_/GdkPixbuf.InterpType./g;" \ + -pe "s/Gdk.COLORSPACE_RGB/GdkPixbuf.Colorspace.RGB/g;" \ +\ + -pe "s/import pango\n/from gi.repository import Pango\n/g;" \ + -pe "s/pango\./Pango\./g;" \ + -pe "s/Pango.ALIGN_/Pango.Alignment./g;" \ + -pe "s/Pango.ELLIPSIZE_/Pango.EllipsizeMode./g;" \ + -pe "s/Pango.STYLE_/Pango.Style./g;" \ + -pe "s/Pango.UNDERLINE_/Pango.Underline./g;" \ + -pe "s/Pango.WEIGHT_/Pango.Weight./g;" \ + -pe "s/Pango.WRAP_/Pango.WrapMode./g;" \ + -pe "s/Pango.TAB_/Pango.TabAlign./g;" \ +\ + -pe "s/import atk\n/from gi.repository import Atk\n/g;" \ + -pe "s/atk\./Atk\./g;" \ + -pe "s/Atk.HYPERLINK_/Atk.HyperlinkStateFlags./g;" \ + -pe "s/Atk.KEY_EVENT_/Atk.KeyEventType./g;" \ + -pe "s/Atk.LAYER_/Atk.Layer./g;" \ + -pe "s/Atk.RELATION_/Atk.RelationType./g;" \ + -pe "s/Atk.ROLE_/Atk.Role./g;" \ + -pe "s/Atk.STATE_/Atk.StateType./g;" \ + -pe "s/Atk.TEXT_ATTR_/Atk.TextAttribute./g;" \ + -pe "s/Atk.TEXT_BOUNDARY_/Atk.TextBoundary./g;" \ + -pe "s/Atk.TEXT_CLIP_/Atk.TextClipType./g;" \ +\ + -pe "s/import gio\n/from gi.repository import Gio\n/g;" \ + -pe "s/gio\./Gio\./g;" \ + -pe "s/Gio.FILE_COPY_/Gio.FileCopyFlags./g;" \ + -pe "s/Gio.FILE_CREATE_/Gio.FileCreateFlags./g;" \ + -pe "s/Gio.FILE_MONITOR_EVENT_/Gio.FileMonitorEvent./g;" \ + -pe "s/Gio.FILE_MONITOR_/Gio.FileMonitorFlags./g;" \ + -pe "s/Gio.FILE_TYPE_/Gio.FileType./g;" \ + -pe "s/Gio.FILE_QUERY_INFO_/Gio.FileQueryInfoFlags./g;" \ + -pe "s/Gio.MOUNT_MOUNT_/Gio.MountMountFlags./g;" \ + -pe "s/Gio.MOUNT_OPERATION_/Gio.MountOperationResult./g;" \ + -pe "s/Gio.MOUNT_UNMOUNT_/Gio.MountUnmountFlags./g;" \ + -pe "s/Gio.OUTPUT_STREAM_SPLICE_/Gio.OutputStreamSpliceFlags./g;" \ + -pe "s/Gio.vfs_/Gio.Vfs./g;" \ +\ + -pe "#s/import glib\n/from gi.repository import GLib\n/g;" \ + -pe "#s/(?<!\.)glib\./GLib\./g;" \ + -pe "#s/GLib.IO_(ERR|HUP|IN|NVAL|OUT|PRI)/GLib.IOCondition./g;" \ + -pe "#s/GLib.IO_FLAG_/GLib.IOFlags./g;" \ + -pe "#s/GLib.IO_STATUS_/GLib.IOStatus./g;" \ + -pe "#s/GLib.OPTION_ERROR_/GLib.OptionError./g;" \ + -pe "#s/GLib.OPTION_FLAG_/GLib.OptionFlags./g;" \ + -pe "#s/GLib.SPAWN_/GLib.SpawnFlags./g;" \ + -pe "#s/GLib.USER_DIRECTORY_/GLib.UserDirectory.DIRECTORY_/g;" \ +\ + -pe "s/(?<!\.)gobject\./GObject\./g;" \ + -pe "s/GObject.SIGNAL_/GObject.SignalFlags./g;" \ + -pe "s/GObject.TYPE_NONE/None/g;" \ +\ + -pe "s/import hippo\n/from gi.repository import Hippo\n/g;" \ + -pe "s/hippo\./Hippo\./g;" \ + -pe "s/Hippo\..*\.__init__/gobject.GObject.__init__/g;" \ + -pe "s/Hippo.PACK_/Hippo.PackFlags./g;" \ + -pe "s/Hippo.ORIENTATION_/Hippo.Orientation./g;" \ + -pe "#s/insert_sorted\(([^,\)]*), ([^,\)]*), ([^,\)]*)\)/insert_sorted\(\1, \2, \3, None\)/g;" \ + -pe "s/self\._box\.insert_sorted/#self\._box\.insert_sorted/g;" \ + -pe "s/self._box.append\(([^,\)]*)\)/self._box.append\(\1, 0\)/g;" \ + -pe "s/self.append\(self._buddy_icon\)/self.append\(self._buddy_icon, 0\)/g;" \ + -pe "s/self._box.sort\(([^,\)]*)\)/self._box.sort\(\1, None\)/g;" \ +\ + -pe "s/import wnck\n/from gi.repository import Wnck\n/g;" \ + -pe "s/wnck\./Wnck\./g;" \ + -pe "s/Wnck.screen_get_default/Wnck.Screen.get_default/g;" \ + -pe "s/Wnck.WINDOW_/Wnck.WindowType./g;" \ +\ + -pe "s/from sugar import _sugarext\n/from gi.repository import SugarExt\n/g;" \ + -pe "s/_sugarext\.ICON_ENTRY_/SugarExt.SexyIconEntryPosition./g;" \ + -pe "s/_sugarext\.IconEntry/SugarExt.SexyIconEntry/g;" \ + -pe "s/_sugarext\.SMClientXSMP/SugarExt.GsmClientXSMP/g;" \ + -pe "s/_sugarext\.VolumeAlsa/SugarExt.AcmeVolumeAlsa/g;" \ + -pe "s/_sugarext\./SugarExt\./g;" \ +\ + -pe "s/import gtksourceview2\n/from gi.repository import GtkSource\n/g;" \ + -pe "s/import gtksourceview2 as gsv\n/from gi.repository import GtkSource\n/g;" \ + -pe "s/gtksourceview2\./GtkSource\./g;" \ + -pe "s/gsv\./GtkSource\./g;" \ + -pe "s/GtkSource.DRAW_SPACES_/GtkSource.DrawSpacesFlags./g;" \ + -pe "s/GtkSource.SMART_HOME_END_/GtkSource.SmartHomeEndType./g;" \ + -pe "s/GtkSource.style_scheme_manager_get_default/GtkSource.StyleSchemeManager.get_default/g;" \ + -pe "s/GtkSource.language_manager_get_default/GtkSource.LanguageManager.get_default/g;" \ +\ + -pe "#s/import cairo\n/from gi.repository import cairo\n/g;" \ +\ + -pe "s/SugarExt.xsmp_init\(\)/'mec'/g;" \ + -pe "s/SugarExt.xsmp_run\(\)/#SugarExt.xsmp_run\(\)/g;" \ + -pe "s/SugarExt.session_create_global\(\)/None #SugarExt.session_create_global\(\)/g;" \ + -pe "s/self.session.start\(\)/return #self.session.start\(\)/g;" \ +\ + -pe "s/self._box.sort\(self._layout.compare_activities, None\)/pass #self._box.sort(self._layout.compare_activities, None)/g;" \ + -pe "s/attach_points = info.get_attach_points/has_attach_points_, attach_points = info.get_attach_points/g;" \ + -pe "s/attach_points\[0\]\[0\]/attach_points\[0\].x/g;" \ + -pe "s/attach_points\[0\]\[1\]/attach_points\[0\].y/g;" \ + -pe "s/has_attach_points_/return 0,0;has_attach_points_/g;" \ + -pe "s/gobject.GObject.__init__\(self, self._model_filter\)/gobject.GObject.__init__\(self, model=self._model_filter\)/g;" \ + -pe "s/self._model_filter.set_visible_func/return;self._model_filter.set_visible_func/g;" \ + -pe "s/buddies_column.set_cell_data_func/return;buddies_column.set_cell_data_func/g;" \ + -pe "s/Hippo\.cairo_surface_from_gdk_pixbuf/SugarExt\.cairo_surface_from_pixbuf/g;" \ +\ + -pe "s/import pynotify\n/from gi.repository import Notify\n/g;" \ + -pe "s/pynotify\./Notify\./g;" \ +\ + -pe "s/import webkit\n/from gi.repository import WebKit\n/g;" \ + -pe "s/import clutter\n/from gi.repository import Clutter\n/g;" \ + -pe "s/from clutter import cogl\n/from gi.repository import Cogl\n/g;" \ + -pe "s/(?<!\.)clutter\./Clutter\./g;" \ + -pe "s/(?<!\.)cogl\./Cogl\./g;" \ + -pe "s/Clutter.ACTOR_/Clutter.ActorFlags./g;" \ + -pe "s/Clutter.ALLOCATION_/Clutter.AllocationFlags./g;" \ + -pe "s/Clutter.BIND_/Clutter.BindCoordinate./g;" \ + -pe "s/Clutter.BIN_ALIGNMENT_/Clutter.BinAlignment./g;" \ + -pe "s/Clutter.BOX_ALIGNMENT_/Clutter.BoxAlignment./g;" \ + -pe "s/Clutter.DRAG_/Clutter.DragAxis./g;" \ + -pe "s/Clutter.EASE_/Clutter.AnimationMode./g;" \ + -pe "s/Clutter.FEATURE_/Clutter.FeatureFlags./g;" \ + -pe "s/Clutter.FLOW_/Clutter.FLOW_ORIENTATION./g;" \ + -pe "s/Clutter.FONT_/Clutter.FontFlags./g;" \ + -pe "s/Clutter.GRAVITY_/Clutter.Gravity./g;" \ + -pe "s/Clutter.INTERPOLATION/Clutter.Interpolation./g;" \ + -pe "s/Clutter.LINEAR/Clutter.AnimationMode.LINEAR/g;" \ + -pe "s/Clutter.PATH_/Clutter.PathNodeType./g;" \ + -pe "s/Clutter.PICK_/Clutter.PickMode./g;" \ + -pe "s/Clutter.REQUEST_/Clutter.RequestMode./g;" \ + -pe "s/Clutter.ROTATE_/Clutter.RotateDirection./g;" \ + -pe "s/Clutter.SCRIPT_/Clutter.ScriptError./g;" \ + -pe "s/Clutter.STAGE_STATE_/Clutter.StageState./g;" \ + -pe "s/Clutter.TABLE_ALIGNMENT_/Clutter.TableAlignment./g;" \ + -pe "s/Clutter.TEXTURE_ERROR_/Clutter.TextureError./g;" \ + -pe "s/Clutter.TEXTURE_/Clutter.TextureFlags./g;" \ + -pe "s/Clutter.TEXT_/Clutter.TextDirection./g;" \ + -pe "s/Clutter.TIMELINE_/Clutter.TimelineDirection./g;" \ + -pe "s/Clutter.UNIT_/Clutter.UnitType./g;" \ + -pe "s/Clutter.X_AXIS/Clutter.RotateAxis.X_AXIS/g;" \ + -pe "s/Clutter.Y_AXIS/Clutter.RotateAxis.Y_AXIS/g;" \ + -pe "s/Clutter.Z_AXIS/Clutter.RotateAxis.Z_AXIS/g;" \ + -pe "s/Clutter.ENTER/Clutter.EventType.ENTER/g;" \ + -pe "s/Clutter.LEAVE/Clutter.EventType.LEAVE/g;" \ + -pe "s/Clutter.BUTTON_PRESS/Clutter.EventType.BUTTON_PRESS/g;" \ + -pe "s/Clutter.BUTTON_RELEASE/Clutter.EventType.BUTTON_RELEASE/g;" \ + -pe "s/Clutter.KEY_PRESS/Clutter.EventType.KEY_PRESS/g;" \ + -pe "s/Clutter.KEY_RELEASE/Clutter.EventType.KEY_RELEASE/g;" \ + -pe "s/Clutter.SCROLL/Clutter.EventType.SCROLL/g;" \ + -pe "s/Clutter.DELETE/Clutter.EventType.DELETE/g;" \ + -pe "s/Clutter.CLIENT_MESSAGE/Clutter.EventType.CLIENT_MESSAGE/g;" \ + -pe "s/Clutter.DESTROY_NOTIFY/Clutter.EventType.DESTROY_NOTIFY/g;" \ + -pe "s/Clutter.STAGE_STATE/Clutter.EventType.STAGE_STATE/g;" \ + -pe "s/Clutter.MOTION/Clutter.EventType.MOTION/g;" \ + -pe "s/Clutter.BUTTON1_MASK/Clutter.ModifierType.BUTTON1_MASK/g;" \ + -pe "s/Clutter.BUTTON2_MASK/Clutter.ModifierType.BUTTON2_MASK/g;" \ + -pe "s/Clutter.BUTTON3_MASK/Clutter.ModifierType.BUTTON3_MASK/g;" \ + -pe "s/Clutter.BUTTON4_MASK/Clutter.ModifierType.BUTTON4_MASK/g;" \ + -pe "s/Clutter.BUTTON5_MASK/Clutter.ModifierType.BUTTON5_MASK/g;" \ + -pe "s/Clutter.CONTROL_MASK/Clutter.ModifierType.CONTROL_MASK/g;" \ + -pe "s/Clutter.HYPER_MASK/Clutter.ModifierType.HYPER_MASK/g;" \ + -pe "s/Clutter.LOCK_MASK/Clutter.ModifierType.LOCK_MASK/g;" \ + -pe "s/Clutter.META_MASK/Clutter.ModifierType.META_MASK/g;" \ + -pe "s/Clutter.MOD1_MASK/Clutter.ModifierType.MOD1_MASK/g;" \ + -pe "s/Clutter.MOD2_MASK/Clutter.ModifierType.MOD2_MASK/g;" \ + -pe "s/Clutter.MOD3_MASK/Clutter.ModifierType.MOD3_MASK/g;" \ + -pe "s/Clutter.MOD4_MASK/Clutter.ModifierType.MOD4_MASK/g;" \ + -pe "s/Clutter.MOD5_MASK/Clutter.ModifierType.MOD5_MASK/g;" \ + -pe "s/Clutter.MODIFIER_MASK/Clutter.ModifierType.MODIFIER_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_13_MASK/Clutter.ModifierType.MODIFIER_RESERVED_13_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_14_MASK/Clutter.ModifierType.MODIFIER_RESERVED_14_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_15_MASK/Clutter.ModifierType.MODIFIER_RESERVED_15_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_16_MASK/Clutter.ModifierType.MODIFIER_RESERVED_16_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_17_MASK/Clutter.ModifierType.MODIFIER_RESERVED_17_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_18_MASK/Clutter.ModifierType.MODIFIER_RESERVED_18_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_19_MASK/Clutter.ModifierType.MODIFIER_RESERVED_19_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_20_MASK/Clutter.ModifierType.MODIFIER_RESERVED_20_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_21_MASK/Clutter.ModifierType.MODIFIER_RESERVED_21_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_22_MASK/Clutter.ModifierType.MODIFIER_RESERVED_22_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_23_MASK/Clutter.ModifierType.MODIFIER_RESERVED_23_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_24_MASK/Clutter.ModifierType.MODIFIER_RESERVED_24_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_25_MASK/Clutter.ModifierType.MODIFIER_RESERVED_25_MASK/g;" \ + -pe "s/Clutter.MODIFIER_RESERVED_29_MASK/Clutter.ModifierType.MODIFIER_RESERVED_29_MASK/g;" \ + -pe "s/Clutter.RELEASE_MASK/Clutter.ModifierType.RELEASE_MASK/g;" \ + -pe "s/Clutter.SHIFT_MASK/Clutter.ModifierType.SHIFT_MASK/g;" \ + -pe "s/Clutter.SUPER_MASK/Clutter.ModifierType.SUPER_MASK/g;" \ + $f +done + + diff --git a/pygtkcompat/pygtkcompat.py b/pygtkcompat/pygtkcompat.py index 7b37599..18ebd7b 100644 --- a/pygtkcompat/pygtkcompat.py +++ b/pygtkcompat/pygtkcompat.py @@ -71,7 +71,12 @@ def _install_enums(module, dest=None, strip=''): try: if issubclass(obj, GObject.GFlags): for value, flag in obj.__flags_values__.items(): - name = flag.value_names[-1].replace(modname + '_', '') + try: + name = flag.value_names[-1].replace(modname + '_', '') + except IndexError: + # FIXME: this happens for some large flags which do not + # fit into a long on 32 bit systems + continue setattr(dest, name, flag) except TypeError: continue diff --git a/tests/Makefile.am b/tests/Makefile.am index a91c814..77efd2e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,6 +88,7 @@ EXTRA_DIST = \ test_gobject.py \ test_gtype.py \ test_interface.py \ + test_internal_api.py \ test_iochannel.py \ test_mainloop.py \ test_option.py \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 60fc5cc..5aa69dc 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -334,6 +334,7 @@ EXTRA_DIST = \ test_gobject.py \ test_gtype.py \ test_interface.py \ + test_internal_api.py \ test_iochannel.py \ test_mainloop.py \ test_option.py \ diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py index bb5f2d9..805633a 100644 --- a/tests/test_gdbus.py +++ b/tests/test_gdbus.py @@ -133,7 +133,9 @@ class TestGDBusClient(unittest.TestCase): self.dbus_proxy.GetConnectionUnixProcessID('(s)', '1', timeout=0) self.fail('call with timeout=0 should raise an exception') except Exception as e: - self.assertTrue('Timeout' in str(e), str(e)) + # FIXME: this is not very precise, but in some environments we + # do not always get an actual timeout + self.assertTrue(isinstance(e, GLib.GError), str(e)) def test_python_calls_sync_noargs(self): # methods without arguments don't need an explicit signature diff --git a/tests/test_gi.py b/tests/test_gi.py index 4837204..a2664f1 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -711,6 +711,7 @@ class TestFilename(unittest.TestCase): dirname = GLib.Dir.make_tmp('testäø.XXXXXX') self.assertTrue('/testäø.' in dirname, dirname) + dirname = _bytes(dirname) self.assertTrue(os.path.isdir(dirname)) os.rmdir(dirname) @@ -958,6 +959,11 @@ class TestGArray(unittest.TestCase): def test_garray_utf8_full_out(self): self.assertEqual(['0', '1', '2'], GIMarshallingTests.garray_utf8_full_out()) + @unittest.skipUnless(hasattr(GIMarshallingTests, 'garray_utf8_full_out_caller_allocated'), + 'too old gobject-introspection') + def test_garray_utf8_full_out_caller_allocated(self): + self.assertEqual(['0', '1', '2'], GIMarshallingTests.garray_utf8_full_out_caller_allocated()) + def test_garray_utf8_none_inout(self): self.assertEqual(['-2', '-1', '0', '1'], GIMarshallingTests.garray_utf8_none_inout(Sequence(('0', '1', '2')))) @@ -1355,6 +1361,42 @@ class TestGClosure(unittest.TestCase): self.assertRaises(TypeError, GIMarshallingTests.gclosure_in, None) +class TestCallbacks(unittest.TestCase): + def test_return_value_only(self): + def cb(): + return 5 + self.assertEqual(GIMarshallingTests.callback_return_value_only(cb), 5) + + @unittest.expectedFailure + def test_one_out_arg(self): + def cb(): + return 5.5 + self.assertAlmostEqual(GIMarshallingTests.callback_one_out_parameter(cb), 5.5) + + @unittest.expectedFailure + def test_multiple_out_args(self): + def cb(): + return (5.5, 42.0) + res = GIMarshallingTests.callback_multiple_out_parameters(cb) + self.assertAlmostEqual(res[0], 5.5) + self.assertAlmostEqual(res[1], 42.0) + + @unittest.expectedFailure + def test_return_and_one_out_arg(self): + def cb(): + return (5, 42.0) + res = GIMarshallingTests.callback_return_value_and_one_out_parameter(cb) + self.assertEqual(res[0], 5) + self.assertAlmostEqual(res[1], 42.0) + + @unittest.expectedFailure + def test_return_and_multiple_out_arg(self): + def cb(): + return (5, 42, -1000) + self.assertEqual(GIMarshallingTests.callback_return_value_and_multiple_out_parameters(cb), + (5, 42, -1000)) + + class TestPointer(unittest.TestCase): def test_pointer_in_return(self): self.assertEqual(GIMarshallingTests.pointer_in_return(42), 42) @@ -1916,6 +1958,15 @@ class TestPythonGObject(unittest.TestCase): def do_method_int8_out(self): return 42 + def do_method_int8_arg_and_out_caller(self, arg): + return arg + 1 + + def do_method_int8_arg_and_out_callee(self, arg): + return arg + 1 + + def do_method_str_arg_out_ret(self, arg): + return (arg.upper(), len(arg)) + def do_method_with_default_implementation(self, int8): GIMarshallingTests.Object.do_method_with_default_implementation(self, int8) self.props.int += int8 @@ -1971,6 +2022,12 @@ class TestPythonGObject(unittest.TestCase): self.assertEqual(object_.val, 84) self.assertEqual(object_.method_int8_out(), 42) + # can be dropped when bumping g-i dependencies to >= 1.35.2 + if hasattr(object_, 'method_int8_arg_and_out_caller'): + self.assertEqual(object_.method_int8_arg_and_out_caller(42), 43) + self.assertEqual(object_.method_int8_arg_and_out_callee(42), 43) + self.assertEqual(object_.method_str_arg_out_ret('hello'), ('HELLO', 5)) + object_.method_with_default_implementation(42) self.assertEqual(object_.props.int, 84) @@ -2302,8 +2359,16 @@ class TestOverrides(unittest.TestCase): self.assertTrue(isinstance(object_, GIMarshallingTests.OverridesObject)) def test_module_name(self): + # overridden types self.assertEqual(GIMarshallingTests.OverridesStruct.__module__, 'gi.overrides.GIMarshallingTests') - self.assertEqual(GObject.InitiallyUnowned.__module__, 'gi.repository.GObject') + self.assertEqual(GIMarshallingTests.OverridesObject.__module__, 'gi.overrides.GIMarshallingTests') + self.assertEqual(GObject.Object.__module__, 'gi.overrides.GObject') + + # not overridden + self.assertEqual(GIMarshallingTests.SubObject.__module__, 'gi.repository.GIMarshallingTests') + # FIXME: does not work with TEST_NAMES='test_thread test_gi.TestOverrides', + # it is importlib._bootstrap then + #self.assertEqual(GObject.InitiallyUnowned.__module__, 'gi.repository.GObject') class TestDir(unittest.TestCase): diff --git a/tests/test_glib.py b/tests/test_glib.py index 1a45fd8..9ef60e4 100644 --- a/tests/test_glib.py +++ b/tests/test_glib.py @@ -36,8 +36,10 @@ class TestGLib(unittest.TestCase): self.assertEqual(GLib.get_application_name(), 'moo') def test_xdg_dirs(self): - self.assertTrue(os.path.isdir(GLib.get_user_data_dir())) - self.assertTrue(os.path.isdir(GLib.get_user_special_dir(GLib.USER_DIRECTORY_DESKTOP))) + d = GLib.get_user_data_dir() + self.assertTrue('/' in d, d) + d = GLib.get_user_special_dir(GLib.USER_DIRECTORY_DESKTOP) + self.assertTrue('/' in d, d) # also works with backwards compatible enum names self.assertEqual(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC), GLib.get_user_special_dir(GLib.USER_DIRECTORY_MUSIC)) @@ -45,7 +47,7 @@ class TestGLib(unittest.TestCase): for d in GLib.get_system_config_dirs(): self.assertTrue('/' in d, d) for d in GLib.get_system_data_dirs(): - self.assertTrue('/' in d, d) + self.assertTrue(isinstance(d, str), d) def test_main_depth(self): self.assertEqual(GLib.main_depth(), 0) @@ -171,6 +173,9 @@ https://my.org/q?x=1&y=2 def cb(file, condition): call_data.append((file, condition, file.readline())) + if len(call_data) == 2: + # avoid having to wait for the full timeout + ml.quit() return True # io_add_watch() takes an IOChannel, calling with a Python file is deprecated @@ -180,7 +185,7 @@ https://my.org/q?x=1&y=2 self.assertTrue(issubclass(warn[0].category, PyGIDeprecationWarning)) ml = GLib.MainLoop() - GLib.timeout_add(400, ml.quit) + GLib.timeout_add(2000, ml.quit) ml.run() cmd.wait() diff --git a/tests/test_internal_api.py b/tests/test_internal_api.py new file mode 100644 index 0000000..ca50f6b --- /dev/null +++ b/tests/test_internal_api.py @@ -0,0 +1,73 @@ +# -*- Mode: Python -*- + +import unittest + +from gi.repository import GLib, GObject + +import testhelper +import testmodule + + +class TestObject(unittest.TestCase): + def test_create_ctor(self): + o = testmodule.PyGObject() + self.assertTrue(isinstance(o, GObject.Object)) + self.assertTrue(isinstance(o, testmodule.PyGObject)) + + # has expected property + self.assertEqual(o.props.label, 'hello') + o.props.label = 'goodbye' + self.assertEqual(o.props.label, 'goodbye') + self.assertRaises(AttributeError, getattr, o.props, 'nosuchprop') + + def test_pyobject_new_test_type(self): + o = testhelper.create_test_type() + self.assertTrue(isinstance(o, testmodule.PyGObject)) + + # has expected property + self.assertEqual(o.props.label, 'hello') + o.props.label = 'goodbye' + self.assertEqual(o.props.label, 'goodbye') + self.assertRaises(AttributeError, getattr, o.props, 'nosuchprop') + + def test_new_refcount(self): + # TODO: justify why this should be 2 + self.assertEqual(testhelper.test_g_object_new(), 2) + + +class TestGValueConversion(unittest.TestCase): + def test_int(self): + self.assertEqual(testhelper.test_value(0), 0) + self.assertEqual(testhelper.test_value(5), 5) + self.assertEqual(testhelper.test_value(-5), -5) + self.assertEqual(testhelper.test_value(GObject.G_MAXINT32), GObject.G_MAXINT32) + self.assertEqual(testhelper.test_value(GObject.G_MININT32), GObject.G_MININT32) + + def test_str(self): + self.assertEqual(testhelper.test_value('hello'), 'hello') + + def test_int_array(self): + self.assertEqual(testhelper.test_value_array([]), []) + self.assertEqual(testhelper.test_value_array([0]), [0]) + ar = list(range(100)) + self.assertEqual(testhelper.test_value_array(ar), ar) + + def test_str_array(self): + self.assertEqual(testhelper.test_value_array([]), []) + self.assertEqual(testhelper.test_value_array(['a']), ['a']) + ar = ('aa ' * 1000).split() + self.assertEqual(testhelper.test_value_array(ar), ar) + + +class TestErrors(unittest.TestCase): + def test_gerror(self): + callable_ = lambda: GLib.file_get_contents('/nonexisting ') + self.assertRaises(GLib.GError, testhelper.test_gerror_exception, callable_) + + def test_no_gerror(self): + callable_ = lambda: GLib.file_get_contents(__file__) + self.assertEqual(testhelper.test_gerror_exception(callable_), None) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py index 6148479..7ed8344 100644 --- a/tests/test_overrides_gtk.py +++ b/tests/test_overrides_gtk.py @@ -277,9 +277,15 @@ class TestGtk(unittest.TestCase): self.assertEqual('color selection dialog test', dialog.get_title()) # Gtk.FileChooserDialog - dialog = Gtk.FileChooserDialog(title='file chooser dialog test', - buttons=('test-button1', 1), - action=Gtk.FileChooserAction.SAVE) + # might cause a GVFS warning, do not break on this + old_mask = GLib.log_set_always_fatal( + GLib.LogLevelFlags.LEVEL_CRITICAL | GLib.LogLevelFlags.LEVEL_ERROR) + try: + dialog = Gtk.FileChooserDialog(title='file chooser dialog test', + buttons=('test-button1', 1), + action=Gtk.FileChooserAction.SAVE) + finally: + GLib.log_set_always_fatal(old_mask) self.assertTrue(isinstance(dialog, Gtk.Dialog)) self.assertTrue(isinstance(dialog, Gtk.Window)) diff --git a/tests/test_properties.py b/tests/test_properties.py index ccb80a6..fe286e2 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -16,7 +16,8 @@ from gi.repository.GObject import \ TYPE_STRING, TYPE_PYOBJECT, TYPE_VARIANT from gi.repository.GObject import \ - G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, G_MAXULONG + G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, G_MAXULONG, \ + G_MAXUINT64, G_MAXINT64, G_MININT64 from gi.repository import Gio from gi.repository import GLib @@ -584,17 +585,13 @@ class TestProperty(unittest.TestCase): self.assertEqual(o.prop_name, 10) def test_range(self): - maxint64 = 2 ** 62 - 1 - minint64 = -2 ** 62 - 1 - maxuint64 = 2 ** 63 - 1 - types_ = [ (TYPE_INT, G_MININT, G_MAXINT), (TYPE_UINT, 0, G_MAXUINT), (TYPE_LONG, G_MINLONG, G_MAXLONG), (TYPE_ULONG, 0, G_MAXULONG), - (TYPE_INT64, minint64, maxint64), - (TYPE_UINT64, 0, maxuint64), + (TYPE_INT64, G_MININT64, G_MAXINT64), + (TYPE_UINT64, 0, G_MAXUINT64), ] for gtype, min, max in types_: |