From: DongHun Kwak Date: Tue, 11 Jul 2017 23:35:07 +0000 (+0900) Subject: Imported Upstream version 2.26.0 X-Git-Tag: upstream/2.27.0~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df82aa0a770d4b3e52e96eb5c60b528ddcdb2343;p=platform%2Fupstream%2Fpygobject2.git Imported Upstream version 2.26.0 Change-Id: I616aeca320e366d54dd6e188c260b64639305c49 Signed-off-by: DongHun Kwak --- diff --git a/ChangeLog b/ChangeLog index c2dca80..fcc73b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,1430 @@ +commit fd38010101411e6bc1ca9314657f418de660fa13 +Author: John (J5) Palmieri +Date: Mon Sep 27 12:03:10 2010 -0400 + + update NEWS for release + + NEWS | 93 + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 93 insertions(+), 0 deletions(-) + +commit 7072d56b6cba13da97a052c75d1ae0c2cc417fd1 +Author: Tomeu Vizoso +Date: Sun Sep 26 08:37:31 2010 +0200 + + Pre-release version bump 2.26.0 + + configure.ac | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +commit a549f429d2ced7a78d5baa5e2f28f6750b4788f2 +Author: John Stowers +Date: Fri Sep 24 22:44:03 2010 +1200 + + Wrap g_get_system_{config,data}_dirs () + + * Also tidy up g_get_{cache,config,data}_dir + to share common code + + glib/glibmodule.c | 68 + +++++++++++++++++++++++++++++++++++++++-------------- + 1 files changed, 50 insertions(+), 18 deletions(-) + +commit 328aca600714bdca89dfdb531c222ee561ede27e +Author: John (J5) Palmieri +Date: Fri Sep 24 12:16:22 2010 -0400 + + fixed make check and make dist + + tests/Makefile.am | 31 ++++++++++++++++++------------- + 1 files changed, 18 insertions(+), 13 deletions(-) + +commit 27023fd56148dd17b5576c1e81e0fe851d9b8727 +Author: John Stowers +Date: Fri Sep 24 21:20:53 2010 +1200 + + Disable GI tests when introspection disabled + + tests/Makefile.am | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +commit 7fe831081cdd2e26f5d948326b9f89ea0694e752 +Author: Tomeu Vizoso +Date: Sat Jul 18 19:35:08 2009 +0200 + + Wrap g_uri_list_extract_uris. Fixes bug #584431 + + glib/glibmodule.c | 38 ++++++++++++++++++++++++++++++++++++++ + gobject/__init__.py | 2 +- + tests/Makefile.am | 3 ++- + tests/test_uris.py | 15 +++++++++++++++ + 4 files changed, 56 insertions(+), 2 deletions(-) + +commit d6721a59c294f2471142b8c32de2f647b7084bca +Author: Paul Bolle +Date: Thu Sep 23 15:38:40 2010 -0400 + + Fix a few uses of TRUE and FALSE in the docs + + docs/reference/pygio-mount.xml | 5 +++-- + docs/reference/pyglib-functions.xml | 18 +++++++++--------- + docs/reference/pyglib-maincontext.xml | 12 ++++++------ + docs/reference/pyglib-mainloop.xml | 6 +++--- + docs/reference/pygobject-functions.xml | 6 +++--- + docs/reference/pygobject.xml | 4 ++-- + 6 files changed, 26 insertions(+), 25 deletions(-) + +commit a08c9fffb4262ae678e17f90bbfb2d5f880cfad0 +Author: Damien Caliste +Date: Tue Sep 21 17:52:14 2010 +0200 + + pygi: always free the invocation_state struct + + In pygi-invoke.c, the invocation_state struct is never freed + in case of success. Thus, always call _free_invocation_state() + before leaving. + Modify _free_invocation_state to avoid double free in case of + caller-allocated GValue, once as a released argument in the + _process routine and another time in the _free as the special + case. So move all argument releasing code from the _process + routine to the _free one. + Modify the tests for the callback routines to return an integer + value as specified in the GIR file. + + Make check is as successful as before (already existing error + related to GVariant is still there). + + https://bugzilla.gnome.org/show_bug.cgi?id=630271 + + gi/pygi-invoke.c | 83 + ++++++++++++++++++++------------------------- + tests/test_everything.py | 4 ++- + 2 files changed, 40 insertions(+), 47 deletions(-) + +commit 9714d765a34e246899f11b6792eea3aecce0b7ec +Author: Tomeu Vizoso +Date: Mon Sep 13 16:36:47 2010 +0200 + + Start implementing something equivalent to g_variant_new + + https://bugzilla.gnome.org/show_bug.cgi?id=629367 + + gi/gimodule.c | 20 +++++++ + gi/overrides/GLib.py | 131 + +++++++++++++++++++++++++++++++++++++++++-- + gi/pygi-foreign-gvariant.c | 2 +- + tests/test_everything.py | 16 ----- + tests/test_overrides.py | 25 ++++++++ + 5 files changed, 170 insertions(+), 24 deletions(-) + +commit fc45abdd9b55ab63556798ab0f04715be79dba08 +Author: John (J5) Palmieri +Date: Thu Sep 23 10:49:36 2010 -0400 + + fixed typo - missing comma in glib.option module + + * https://bugzilla.gnome.org/show_bug.cgi?id=627449 + + glib/option.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 4ed100f3183c6325dd04461484e877bb7d4131b1 +Author: John (J5) Palmieri +Date: Fri Sep 17 12:08:09 2010 -0400 + + add checks so we can compile under python 3 by setting PYTHON=python3 + + * compile for python 3 + * disables gio if compiling under python 3.x + * runs only pertinant tests + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + configure.ac | 32 +++++++++++++++++++++++++++++--- + tests/Makefile.am | 35 ++++++++++++++++++++--------------- + tests/runtests.py | 4 ++++ + 3 files changed, 53 insertions(+), 18 deletions(-) + +commit 269ff8564eeb597dc06c27e293354b7ff7a71a82 +Author: Tomeu Vizoso +Date: Fri Sep 17 15:50:47 2010 +0200 + + Rename static methods as functions + + In recent gobject-introspection releases, static methods have been + removed and placed as functions in the namespace level. In a future + releases it's planned to become static methods again but for now + let's fix the tests. + + tests/test_gi.py | 14 +++++++------- + 1 files changed, 7 insertions(+), 7 deletions(-) + +commit 2da8da589644d6125101210712defb1272a8abb1 +Author: John (J5) Palmieri +Date: Thu Sep 9 13:52:14 2010 -0400 + + fix a couple of compiler warnings + + https://bugzilla.gnome.org/show_bug.cgi?id=629199 + + gi/pygi-argument.c | 4 ++-- + gi/pygi-struct.c | 2 +- + gobject/gobjectmodule.c | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +commit 6769a4704f0876ac3baacd4da03ff16d9f0906be +Author: John (J5) Palmieri +Date: Thu Sep 9 13:55:17 2010 -0400 + + remove unused code + + * we use richcompare now + + https://bugzilla.gnome.org/show_bug.cgi?id=629198 + + gobject/pygtype.c | 9 --------- + 1 files changed, 0 insertions(+), 9 deletions(-) + +commit 98f54f9d33996baeaa8c8c1240310f5396d03a1d +Author: John (J5) Palmieri +Date: Tue Sep 14 14:10:49 2010 -0400 + + Check the type of the instance object + + * in python 2 methods were added to classes as unbound methods and + they would + check the instance type to make sure it was correct + * in python 3 for perfomance reasons methods are added to classes + as simple + functions which treat the instance as an untyped argument so + no checks + are made. + * this patch adds a type check so that the correct errors are + thrown in + python 3 (python 2 this just adds another layer of redundancy should + something change with type checking in the future) + * since GI handles regular args and the instance arg slightly + differently + we had to split out the interface checks in + _pygi_g_type_info_check_object + in order to not duplicate code + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-argument.c | 182 + +++++++++++++++++++++++++++------------------------ + gi/pygi-argument.h | 2 + + gi/pygi-invoke.c | 14 ++++ + 3 files changed, 112 insertions(+), 86 deletions(-) + +commit 5d79498d38b147b66ae72c1481e397160491e8d6 +Author: John (J5) Palmieri +Date: Wed Sep 15 10:26:20 2010 -0400 + + include the correct pycairo version + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-foreign-cairo.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +commit b855562e5c0019cd7e4982fe00c467ede9e3926d +Author: John (J5) Palmieri +Date: Thu Sep 9 22:16:58 2010 -0400 + + Use PyMapping_Keys to determine if an object is a dict (py3k fix) + + * in Py3k PyMapping_Check returns true for sequences such as strings + and lists. Since we need to get the keys anyway, and it returns + NULL if this is not a dict, this is a much better test, even in + Py2 + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-argument.c | 10 +++------- + 1 files changed, 3 insertions(+), 7 deletions(-) + +commit 0e72e28c6c5502c7db5103cf1299c9f0e6689fdd +Author: John (J5) Palmieri +Date: Thu Sep 9 18:44:11 2010 -0400 + + fix handling of UINT64 and INT64 arguments in py3k + + * decode to the right sized C long + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-argument.c | 20 ++++++++++++-------- + 1 files changed, 12 insertions(+), 8 deletions(-) + +commit d5666d99a1c0396b7da0cb14f9f4ff8892da7e2e +Author: John (J5) Palmieri +Date: Thu Sep 9 17:35:10 2010 -0400 + + properly handle ulongs properties in py3k + + * If this is a PyLong object pull use AsUnsignedLong + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gobject/pygtype.c | 31 +++++++++++++++++-------------- + 1 files changed, 17 insertions(+), 14 deletions(-) + +commit 3d431c7dd0de97db10cb0c00c39d9c1837bed2f2 +Author: Tomeu Vizoso +Date: Fri Sep 17 12:14:56 2010 +0200 + + Specify encoding of tests/test_gi.py + + tests/test_gi.py | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +commit a808bdabb9fa6f4a9b9ce42e1cce05fb37403f0f +Author: John (J5) Palmieri +Date: Thu Sep 9 13:24:30 2010 -0400 + + use actual unicode in the tests on py3k, not the byte representation + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + tests/test_gi.py | 6 +++++- + 1 files changed, 5 insertions(+), 1 deletions(-) + +commit 928f4485041d80d0c36ff2daeae4bcd09bd0bde4 +Author: John (J5) Palmieri +Date: Thu Sep 9 12:45:21 2010 -0400 + + s/METH_KEYWORDS/METH_VARARGS|METH_KEYWORDS/ when defining object + methods + + * in Py3k the METH_KEYWORDS flag by itself is invalid. A method + must be defined + with both the METH_VARARGS and METH_KEYWORDS flags. + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/pygiochannel.c | 30 +++++++++++++++--------------- + glib/pygsource.c | 4 ++-- + gobject/pygobject.c | 2 +- + 3 files changed, 18 insertions(+), 18 deletions(-) + +commit b5ee20afa4399c7689fbec8939fa20b927eeb782 +Author: John (J5) Palmieri +Date: Thu Sep 9 08:04:40 2010 -0400 + + fix subclassing PyLong by calling __new__ correctly + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/pygspawn.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +commit a499b2f0d622b671bd154544f66b73f1278e66ed +Author: John (J5) Palmieri +Date: Thu Sep 9 07:56:44 2010 -0400 + + minor py3k fixups for python modules + + * add _basestring and _bytes and _callable wrappers + * use items instead of iteritems and range instead of xrange + + fix py3k modules + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/overrides/Gtk.py | 24 ++++++++++++++++-------- + glib/option.py | 16 ++++++++++++---- + 2 files changed, 28 insertions(+), 12 deletions(-) + +commit dec9001d26c97949e7b3578086cb35e98075c047 +Author: John (J5) Palmieri +Date: Thu Sep 9 07:36:04 2010 -0400 + + minor fixes in tests for py3k compat + + * add a _bytes wrapper for API that expects bytes in py3k but str + in py2 + * fix some more exception handling using sys.exc_info()[:2] + * use range instead of xrange, items instead of iteritems since py3k + dropped support for the different ways of accessing iterators + - this is less efficient in py2 but we plan to target py3k as the + primary platform + * use list(dict.items()) since py3k only returns iterables which + are not + indexable + * missed some _long wrapping + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + tests/compathelper.py | 18 ++++++++++++++++++ + tests/test_everything.py | 5 +++-- + tests/test_mainloop.py | 3 ++- + tests/test_option.py | 6 ++++-- + tests/test_overrides.py | 4 ++-- + tests/test_properties.py | 6 +++--- + 6 files changed, 32 insertions(+), 10 deletions(-) + +commit 09a0daeedf49eaf376c1288be5743b57fbc76d51 +Author: Colin Walters +Date: Thu Sep 9 16:25:51 2010 -0400 + + compilation: Fix syntax error + + gi/pygi-info.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 9f7afd6d5afd8c1a5f36bf1295814757b71c8cbc +Author: Tomeu Vizoso +Date: Thu Sep 9 22:17:00 2010 +0200 + + Add missing file + + gi/overrides/GLib.py | 48 + ++++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 48 insertions(+), 0 deletions(-) + +commit 306b792ac97a458ddee59fb86d66453495117f3e +Author: Tomeu Vizoso +Date: Thu Jul 22 13:48:51 2010 +0100 + + Add override for GLib.Variant.new_tuple + + * gi/gimodule.c: Add _wrap_pyg_variant_new_tuple + * gi/overrides/GLib.py: Override Variant.new_tuple and + Variant.get_string + * gi/pygi-type.[hc]: split _pygi_type_import_by_name out from + _pygi_type_import_by_gi_info + * gi/types.py: Never override gobject.TYPE_NONE + * tests/test_everything.py: Add tests for GVariant tuples + + https://bugzilla.gnome.org/show_bug.cgi?id=625050 + + gi/gimodule.c | 38 ++++++++++++++++++++++++++++++++++++++ + gi/overrides/Makefile.am | 1 + + gi/pygi-type.c | 15 +++++++++------ + gi/pygi-type.h | 2 ++ + gi/types.py | 1 + + tests/test_everything.py | 9 +++++++++ + 6 files changed, 60 insertions(+), 6 deletions(-) + +commit 22e53aa2ed9cf6173a877b0af6928d5ab8da2f4f +Author: John (J5) Palmieri +Date: Wed Sep 8 13:08:48 2010 -0400 + + fix for changes in the gi test libraries + + tests/test_everything.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 246877074617b0e9c3b2ba2a5395a73e0ed9cd5d +Author: John (J5) Palmieri +Date: Wed Sep 8 13:08:07 2010 -0400 + + Gtk.DialogFlags.NO_SEPARATOR has been removed in Gtk 3.0 + + gi/overrides/Gtk.py | 10 ++++++++-- + 1 files changed, 8 insertions(+), 2 deletions(-) + +commit f92fc48e7e2ec50996e994ccb7d08a61e7374f22 +Author: John (J5) Palmieri +Date: Wed Sep 8 12:35:09 2010 -0400 + + no need to offset arg positions when is_method is true + + * The old GI libraries required we offset arg positions for the + missing + self argument. The new library fixes this so we don't have + to offset + anymore. + + https://bugzilla.gnome.org/show_bug.cgi?id=629087 + + gi/pygi-callbacks.c | 5 +---- + 1 files changed, 1 insertions(+), 4 deletions(-) + +commit 8c517de2d278bdef641c72b8f2919a3924290ec1 +Author: Tomeu Vizoso +Date: Fri Aug 20 14:54:35 2010 +0200 + + gi: Add support for more property types + + https://bugzilla.gnome.org/show_bug.cgi?id=627494 + + gi/pygi-property.c | 156 + +++++++++++++++++++++++++++++++++++----------- + tests/test_everything.py | 34 ++++++++++ + 2 files changed, 154 insertions(+), 36 deletions(-) + +commit 6d183d1fff55d54569ba3e1f90a10284df74fd40 +Author: John (J5) Palmieri +Date: Fri Sep 3 12:04:16 2010 -0400 + + use PyObject_SetAttrString, not PyDict_SetItemString when setting + __gtype__ + + * When registering a gtype wrapper we used to set tp_dict + directly. This works + in python 2 but python 3 seems to handle attributes in a slightly + different + way where the tp_dict and attr get out of sync. By setting the attr + directly we avoid this issue. + * Note that there are many more places where we set __gtype__ + using tp_dict + however for objects which are not instantiated yet we have to + set tp_dict + directly. + * Since this one change fixes a lot of failed tests, for now we + ignore the + other places where we set __gtype__. If we run into more issues + dealing + with __gtype__ we can take a closer look later. + + https://bugzilla.gnome.org/show_bug.cgi?id=627878 + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gobject/gobjectmodule.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit b7bf4269682a3335f5e0a52b46fa721af134d09a +Author: Tomeu Vizoso +Date: Wed Sep 1 11:03:40 2010 +0200 + + Rename GArgument to GIArgument + + gi/pygi-argument.c | 52 + ++++++++++++++++++++++---------------------- + gi/pygi-argument.h | 10 ++++---- + gi/pygi-closure.c | 34 ++++++++++++++-------------- + gi/pygi-foreign-cairo.c | 8 +++--- + gi/pygi-foreign-gvariant.c | 4 +- + gi/pygi-foreign-gvariant.h | 4 +- + gi/pygi-foreign.c | 12 +++++----- + gi/pygi-foreign.h | 8 +++--- + gi/pygi-info.c | 8 +++--- + gi/pygi-invoke.c | 28 +++++++++++----------- + gi/pygi-property.c | 4 +- + gi/pygi.h | 16 ++++++------ + 12 files changed, 94 insertions(+), 94 deletions(-) + +commit 7197f85c9be2b03636639ac909ca2c3170653509 +Author: John (J5) Palmieri +Date: Wed Aug 18 10:29:19 2010 -0400 + + fix up tests so they run in py3k + + * add a compat helper that should only be used by tests + * fix long notation to use the compat helper instead + * add parens to print statements + * use compatable try/except pattern + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gobject/propertyhelper.py | 16 +++++++++++----- + tests/compathelper.py | 32 ++++++++++++++++++++++++++++++++ + tests/test_option.py | 7 ++++++- + tests/test_properties.py | 24 ++++++++++++++---------- + tests/test_signal.py | 14 +++++++------- + tests/test_source.py | 4 ++-- + 6 files changed, 72 insertions(+), 25 deletions(-) + +commit 720e614acdbcf734d4bcccc403e639b5a5bcae24 +Author: Colin Walters +Date: Fri Aug 20 10:58:48 2010 -0400 + + tests: Port to new introspection tests + + Everything is renamed "Regress", and both it and GIMarshallingTests + are now in source form, so we compile them. + + The scanner now adds "static methods" to objects, structs, and unions, + so update the test code to use those. + + In the tests, remove broken (inout) cases - the person writing these + tests misunderstood the semantics of (inout). It's not acceptable for + a C API to mutate e.g. a GSList* passed in, or unref an object. + + The invocation code needed to be updated for this - remove some + broken hacks. + + https://bugzilla.gnome.org/show_bug.cgi?id=627878 + + configure.ac | 5 +- + gi/pygi-argument.c | 9 +-- + gi/pygi-invoke.c | 147 + +++++---------------------------------------- + tests/Makefile.am | 42 ++++++++++++- + tests/test_everything.py | 6 +- + tests/test_gi.py | 151 + +++++++++------------------------------------- + 6 files changed, 93 insertions(+), 267 deletions(-) + +commit f6c4d9e58c8f05cb2d82e158c9eb8480308565bd +Author: John (J5) Palmieri +Date: Fri Aug 20 10:43:58 2010 -0400 + + we need to specify tp_hash since we overide tp_richcompare + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gobject/pygenum.c | 1 + + gobject/pygflags.c | 1 + + 2 files changed, 2 insertions(+), 0 deletions(-) + +commit c03e6b482548aee99362356807c804f8834fad2b +Author: John Ehresman +Date: Thu Apr 15 17:11:30 2010 -0400 + + working enum/flags/pid subclasses of long + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/pygspawn.c | 7 +++-- + gobject/pygenum.c | 61 ++++++++++++++++++++++++------------------ + gobject/pygflags.c | 76 + ++++++++++++++++++++++------------------------------ + 3 files changed, 71 insertions(+), 73 deletions(-) + +commit 0db676fd2296750a46ba0fb069e472da06ecc53a +Author: John (J5) Palmieri +Date: Wed Aug 18 11:03:32 2010 -0400 + + make vfuncs work in py3k + + * methods now export __func__ instead of im_func for getting the + function + out of a method closure + * however classes no longer return unbound methods in py3k and instead + return the actual function + * in python 2 we use im_func when getting the function from the + vfunc closure + * in py3k we simply assign vfunc to the function + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/types.py | 12 ++++++++---- + 1 files changed, 8 insertions(+), 4 deletions(-) + +commit 286dcd0c6455961d818ac7f05f80f82435abc1dc +Author: John (J5) Palmieri +Date: Tue Aug 17 15:43:42 2010 -0400 + + make cairo module compile in py3k + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/Makefile.am | 2 +- + gi/pygi-foreign-cairo.c | 17 +++++++---------- + 2 files changed, 8 insertions(+), 11 deletions(-) + +commit bda58ec34fc443fe1108afc8532bec50f6fd0b44 +Author: John (J5) Palmieri +Date: Tue Aug 17 02:33:45 2010 -0400 + + fix exceptions so they work in python 3.x + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/module.py | 2 +- + gi/types.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 427a3c8053feca35ccd746575760ac8a0ed50a12 +Author: John (J5) Palmieri +Date: Tue Aug 17 02:24:44 2010 -0400 + + make the gi module compile under 3.x + + * include the compat macros + * use GLIB_MODULE_START/END to define module + * add PyInit__gi to the exported symbols + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/Makefile.am | 2 +- + gi/gimodule.c | 24 +++++++++--------------- + 2 files changed, 10 insertions(+), 16 deletions(-) + +commit 1dee5dcd2b1747b4a4af438c0443d7930e4802db +Author: John (J5) Palmieri +Date: Tue Aug 17 02:14:14 2010 -0400 + + fix up testshelper module so it compiles in python 3.x + + * include the compat header + * fix up PyInts to be PYGLIB_Long + * Use PYGLIB_DEFINE_TYPE macros to define module objects + * Use PYGLIB_MODULE_START/END to define modules + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + tests/Makefile.am | 2 +- + tests/testhelpermodule.c | 221 + ++++++---------------------------------------- + 2 files changed, 28 insertions(+), 195 deletions(-) + +commit 1ff83a2ccb7301c8f675913f1c4f6118ea50b9c7 +Author: John (J5) Palmieri +Date: Mon Aug 16 21:14:27 2010 -0400 + + convert to using PYGLIB_DEFINE_TYPE for module objects + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-boxed.c | 43 ++----------- + gi/pygi-info.c | 171 + ++++++++++++++++++++------------------------------ + gi/pygi-repository.c | 39 ++--------- + gi/pygi-struct.c | 45 ++----------- + 4 files changed, 88 insertions(+), 210 deletions(-) + +commit 1efa2b12913b194d433c17014bc1077271a6ca32 +Author: John (J5) Palmieri +Date: Mon Aug 16 13:51:05 2010 -0400 + + some more p3k PyString and PyInt eradication in GI + + * add the glib dir to the includes list in the build + * make sure we include the compat macros + * add GLIB_PyBytes_FromString to compat macros + * add GLIB_PyNumber_Long to compat macros + * use RichCompare instead of Compare + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/Makefile.am | 2 +- + gi/pygi-argument.c | 96 + ++++++++++++++++++++++++++----------------- + gi/pygi-boxed.c | 1 + + gi/pygi-info.c | 13 ++++-- + gi/pygi-private.h | 23 ++++++++++ + gi/pygi-repository.c | 8 ++- + gi/pygi-struct.c | 1 + + glib/pyglib-python-compat.h | 6 +++ + 8 files changed, 103 insertions(+), 47 deletions(-) + +commit 6b902c66200c1684513a9ef31bdef3f2ff64e4fa +Author: Tomeu Vizoso +Date: Fri Aug 20 09:28:57 2010 +0200 + + pyglib: Fix typo (Leo Singer) + + https://bugzilla.gnome.org/show_bug.cgi?id=627408 + + glib/option.py | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +commit 3cefffecc1317b6ad77a5ed936bfb990d16bf9d3 +Author: Gustavo Noronha Silva +Date: Thu Aug 19 18:45:05 2010 -0300 + + Add defines for size_t and ssize_t conversion functions + + These missing defines cause the resulting module to have unresolved + symbols, rendering it unusable. + + https://bugzilla.gnome.org/show_bug.cgi?id=627440 + + glib/pyglib-python-compat.h | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +commit d45c7031876f355e15409f00f3e50e77d18f8f4b +Author: Colin Walters +Date: Thu Aug 19 17:50:35 2010 -0400 + + pyglib: Fix a compiler warning + + glib/pyglib.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +commit 0fe6828ddce187ac1897a1f02ca1c5480796d5b9 +Author: Tomeu Vizoso +Date: Wed Aug 18 20:36:51 2010 +0200 + + Don't force gtk 2.0 + + pygi-convert.sh | 11 +++++++---- + 1 files changed, 7 insertions(+), 4 deletions(-) + +commit ac59c18a4f2bfff47c862b763aaf1d1cf136a4f5 +Author: Steve Frécinaux +Date: Tue Aug 17 14:49:30 2010 +0200 + + Fix some ref leaks in hook_up_vfunc_implementation() + + https://bugzilla.gnome.org/show_bug.cgi?id=627143 + + gi/gimodule.c | 9 +++++++-- + 1 files changed, 7 insertions(+), 2 deletions(-) + +commit 18ee0db673c2fa42244ab85950bbf4840edb674b +Author: John (J5) Palmieri +Date: Thu Aug 12 12:16:31 2010 -0400 + + handle strings correctly in gio + + gio/gappinfo.override | 5 +++++ + gio/pygio-utils.c | 42 +++++++++++++++++++++++++++++++++++------- + 2 files changed, 40 insertions(+), 7 deletions(-) + +commit 45ab0c03110c911b47519941dfd753326891b5e0 +Author: John (J5) Palmieri +Date: Wed Aug 11 16:13:59 2010 -0400 + + make giomodule compile under py3k + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gio/giomodule.c | 153 + ++++++++++++++++++++++++++++--------------------------- + 1 files changed, 78 insertions(+), 75 deletions(-) + +commit c52f8ed3ae8cb66a03b5695e980770c3f467f755 +Author: John (J5) Palmieri +Date: Wed Aug 11 16:04:48 2010 -0400 + + for py3k we need to do some more processing to get bytes from a + unicode string + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + gi/pygi-argument.c | 31 +++++++++++++++++++++++++++---- + 1 files changed, 27 insertions(+), 4 deletions(-) + +commit de9eae4dfcce856a42cc5c569a5b9683c28d0eeb +Author: John (J5) Palmieri +Date: Wed Aug 11 15:03:55 2010 -0400 + + use Bytes instead of Unicode when reading io + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/pygiochannel.c | 30 ++++++++++++++++++++++++------ + 1 files changed, 24 insertions(+), 6 deletions(-) + +commit 5824ff98175b749dbcfa72d24b994230b6e05377 +Author: John (J5) Palmieri +Date: Mon Aug 9 15:16:51 2010 -0400 + + prefix compat macros with PYGLIB + + * refactor from John Ehresman py3k branch + * fix up some extranious PyString calls + * remove duplicate macros from pyglib.h that are in + pyglib-python-compat.h + * pygobject.h can't import pyglib-python-compat.h so add codepaths + for both Py3k and legacy code instead of using macros + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/glibmodule.c | 48 +++++----- + glib/pygiochannel.c | 46 +++++----- + glib/pyglib-python-compat.h | 153 +++++++++++++++++++++++------- + glib/pyglib.c | 22 ++-- + glib/pyglib.h | 14 --- + glib/pygoptioncontext.c | 4 +- + glib/pygsource.c | 16 ++-- + glib/pygspawn.c | 32 +++--- + gobject/gobjectmodule.c | 216 + +++++++++++++++++++++--------------------- + gobject/pygboxed.c | 2 +- + gobject/pygenum.c | 84 +++++++++--------- + gobject/pygflags.c | 122 ++++++++++++------------ + gobject/pygobject-private.h | 12 +- + gobject/pygobject.c | 46 +++++----- + gobject/pygobject.h | 23 +++++ + gobject/pygparamspec.c | 24 +++--- + gobject/pygpointer.c | 2 +- + gobject/pygtype.c | 170 +++++++++++++++++----------------- + 18 files changed, 563 insertions(+), 473 deletions(-) + +commit 231e934cc01d061e81bb60d35127a133cd0e1793 +Author: John (J5) Palmieri +Date: Mon Aug 16 10:14:04 2010 +0200 + + Gtk.Button unit tests + + https://bugzilla.gnome.org/show_bug.cgi?id=622606 + + tests/test_overrides.py | 10 ++++++++++ + 1 files changed, 10 insertions(+), 0 deletions(-) + +commit f07cfde377e42686c6b80f56cac62338ee333e61 +Author: Johan Dahlin +Date: Mon Aug 16 10:08:38 2010 +0200 + + [Gtk] Add overrides for Button + + https://bugzilla.gnome.org/show_bug.cgi?id=622606 + + gi/overrides/Gtk.py | 13 +++++++++++++ + 1 files changed, 13 insertions(+), 0 deletions(-) + +commit 65a06a7216163c7e65b32c5b5f3388faa7fda5d6 +Author: Simon van der Linden +Date: Thu Aug 12 16:18:58 2010 +0200 + + Make Cairo an optional dependency + + Add the --enable-cairo configure argument. + + https://bugzilla.gnome.org/show_bug.cgi?id=616732 + + configure.ac | 15 ++++++++++++--- + gi/Makefile.am | 20 ++++++++++++-------- + 2 files changed, 24 insertions(+), 11 deletions(-) + +commit b83507263231d9bf47f6c8450583e3d03f0a3b5b +Author: Tomeu Vizoso +Date: Mon Aug 16 09:55:35 2010 +0200 + + Don't import again PyGObject (John Ralls) + + https://bugzilla.gnome.org/show_bug.cgi?id=626996 + + gi/pygi.h | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +commit 0dc3656070f496431829c6e8441ca17129c569f8 +Author: John (J5) Palmieri +Date: Mon Aug 9 16:11:55 2010 -0400 + + move to using richcompare slot instead of compare + + https://bugzilla.gnome.org/show_bug.cgi?id=615872 + + glib/pygiochannel.c | 18 +++++++--- + glib/pyglib.c | 85 + +++++++++++++++++++++++++++++++++++++++++++++++ + glib/pyglib.h | 3 ++ + glib/pygmaincontext.c | 17 ++++++--- + glib/pygmainloop.c | 17 ++++++--- + glib/pygoptioncontext.c | 18 ++++++---- + glib/pygoptiongroup.c | 22 +++++++----- + gobject/pygboxed.c | 18 +++++++--- + gobject/pygobject.c | 44 +++++++++++++++++------- + gobject/pygparamspec.c | 19 +++++++--- + gobject/pygpointer.c | 17 ++++++--- + gobject/pygtype.c | 26 +++++++++++--- + 12 files changed, 233 insertions(+), 71 deletions(-) + +commit b426e531dc53d4b50e572a2da19733479635e662 +Author: Simon van der Linden +Date: Thu Aug 12 18:09:33 2010 +0200 + + Replace autogen.sh by a newer version + + It pulls automake 1.10 or 1.11. + Greatly inspired from GLib's. + + https://bugzilla.gnome.org/show_bug.cgi?id=625661 + + autogen.sh | 506 + +++++++----------------------------------------------------- + 1 files changed, 58 insertions(+), 448 deletions(-) + +commit 769645e00d6d055a4cd802454dbfc1bbfcbee691 +Author: Simon van der Linden +Date: Thu Aug 12 14:11:55 2010 +0200 + + Fix some warnings + + pyglib.c: In function ‘pyglib_gerror_exception_check’: + pyglib.c:362: warning: format not a string literal and no format + arguments + pyglib.c:371: warning: format not a string literal and no format + arguments + + gio.override: In function 'pygio_notify_allocate_buffer': + gio.override:144:13: warning: format '%d' expects type 'int', but + argument 3 + has type 'gsize' + + https://bugzilla.gnome.org/show_bug.cgi?id=625437 + + gio/gio.override | 2 +- + glib/pyglib.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit e4c4cccb588b258dbcd21702e6cddcfe9ebe4ffc +Author: Simon van der Linden +Date: Thu Aug 12 11:09:37 2010 +0200 + + Fix caller-allocates emergency free. + + In the state, args, args[i], arg_infos[i], and arg_type_infos[i] + must not be + NULL in order to be able caller-allocates. This patch adds those + conditions. + + Moreover, the interface info needs to be freed afterwards. + + https://bugzilla.gnome.org/show_bug.cgi?id=626684 + + gi/pygi-invoke.c | 9 ++++++++- + 1 files changed, 8 insertions(+), 1 deletions(-) + +commit 0ab967ca40ddcffc2834d4e656bb2010c6b9bdda +Author: Simon van der Linden +Date: Thu Aug 12 10:46:17 2010 +0200 + + Remove useless checks. + + No need to check for state->arg_infos, state->arg_type_infos, and + state->args_is_auxiliary to be NULL, they are always allocated. + + https://bugzilla.gnome.org/show_bug.cgi?id=626684 + + gi/pygi-invoke.c | 14 +++----------- + 1 files changed, 3 insertions(+), 11 deletions(-) + +commit e17be9cd288fee5d7cb174d9d577eb9279044c67 +Author: Tomeu Vizoso +Date: Tue Aug 10 17:40:16 2010 +0200 + + Call valgrind with G_SLICE=always-malloc G_DEBUG=gc-friendly + + tests/Makefile.am | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 8be59c37dd57acc51875c7189ca09d728b729013 +Author: Ignacio Casal Quinteiro +Date: Wed Aug 4 13:43:17 2010 +0200 + + Fix some warnings. + + gi/pygi-argument.c | 2 -- + gi/pygi-invoke.c | 2 +- + gi/pygi-struct.c | 1 - + 3 files changed, 1 insertions(+), 4 deletions(-) + +commit 529eca6054e9a7e2267f1529e317c2373932762f +Author: Simon van der Linden +Date: Fri Jul 30 22:39:40 2010 +0200 + + Add myself as a maintainer + + MAINTAINERS | 4 ++++ + 1 files changed, 4 insertions(+), 0 deletions(-) + +commit caac75a6ed6f671b37e38a78e71b87906a00ac1b +Author: Tomeu Vizoso +Date: Fri Jul 30 14:14:16 2010 +0200 + + Properly allocate boxed structs that are (caller-allocates) + + * gi/pygi-boxed.[hc]: Refactor out the allocation of boxed structs + * gi/pygi-invoke.c: Don't use g_malloc0 for boxed structs that + are (caller-allocates) + * tests/test_overrides.py: Split the TreeView tests + + https://bugzilla.gnome.org/show_bug.cgi?id=625653 + + gi/pygi-boxed.c | 50 + +++++++++++++++++++++++++++++++---------------- + gi/pygi-boxed.h | 10 +++++--- + gi/pygi-invoke.c | 16 +++++--------- + tests/test_overrides.py | 39 +++++++++++++++++------------------ + 4 files changed, 64 insertions(+), 51 deletions(-) + +commit 99c7322898c00a576c7319ea0a7c808446253133 +Author: Toms Baugis +Date: Fri Jul 30 15:44:21 2010 +0200 + + override gdk.Event to return attribute from the proper event object + + https://bugzilla.gnome.org/show_bug.cgi?id=620593 + + gi/overrides/Gdk.py | 48 + +++++++++++++++++++++++++++++++++++++++++++++++ + gi/pygi-invoke.c | 4 --- + tests/test_overrides.py | 10 +++++++++ + 3 files changed, 58 insertions(+), 4 deletions(-) + +commit 55814e722c2ae11310f346790c9221e4fad92b50 +Author: John (J5) Palmieri +Date: Fri Jul 30 06:30:48 2010 -0400 + + check if z# needs an int or Py_ssize_t + + https://bugzilla.gnome.org/show_bug.cgi?id=625438 + + gio/gio.override | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +commit 477315465d0a6d84b51e146e86e254873bc564ff +Author: John (J5) Palmieri +Date: Fri Jul 30 06:43:06 2010 -0400 + + make sure we parse parameters to python object vars not glib vars + + * py_flags was already set up but due to a typo &flags was being + passed + instead + + https://bugzilla.gnome.org/show_bug.cgi?id=625438 + + gio/gfile.override | 8 ++++---- + 1 files changed, 4 insertions(+), 4 deletions(-) + +commit faa7d4eece7ddb698725098970c2478a3b45c4d5 +Author: Paul Bolle +Date: Fri Jul 30 10:56:01 2010 +0200 + + Make an example and a demo work out of the box + + cairo-demo.py and gtk-demo.py need the two (kind of) magic lines + regarding pygtk to work out of the box. So add those. + + Signed-off-by: Paul Bolle + + https://bugzilla.gnome.org/show_bug.cgi?id=625638 + + demos/gtk-demo/gtk-demo.py | 2 ++ + examples/cairo-demo.py | 2 ++ + 2 files changed, 4 insertions(+), 0 deletions(-) + +commit c9da5782e6c633d9af43ee85075e9ee65db09780 +Author: John (J5) Palmieri +Date: Fri Jul 9 13:14:42 2010 -0400 + + make sure caller allocated structs are freed when they go out of scope + + * Move struct transfer checks from pygi-arguments to pygi-invoke + * add better warning if an unknown struct is fully transfered + * only free GValues we create in the invoke cleanup. All other + structs + get cleaned up when they go out of scope in python + * Fixes issues with caller allocated treeiters getting freed to early + * this is a fix to crashes in the current test suite when API's + returning + TreeIters were annotated as out caller-allocates so no new tests + are needed + + https://bugzilla.gnome.org/show_bug.cgi?id=623969 + + gi/pygi-argument.c | 13 +++++-------- + gi/pygi-invoke.c | 46 ++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 45 insertions(+), 14 deletions(-) + +commit e0a85305cd107aae5902e524afd074cd8c329927 +Author: Tomeu Vizoso +Date: Fri Jul 30 10:35:33 2010 +0200 + + Revert "override gdk.Event to return attribute from the proper + event object." + + Pushed by mistake, we still need testcases + + This reverts commit e7bb3954880568884ca66e7751ede689dc2f24f6. + + gi/overrides/Gdk.py | 44 -------------------------------------------- + 1 files changed, 0 insertions(+), 44 deletions(-) + +commit 61ffb8d6d08fcfe638f71ea97ceac3a366e5536d +Author: Paul Bolle +Date: Thu Jul 29 22:55:28 2010 +0200 + + PyGI: properly quit cairo-demo + + Signed-off-by: Paul Bolle + + https://bugzilla.gnome.org/show_bug.cgi?id=625619 + + examples/cairo-demo.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit e7bb3954880568884ca66e7751ede689dc2f24f6 +Author: Toms Baugis +Date: Tue Jul 27 21:37:16 2010 +0200 + + override gdk.Event to return attribute from the proper event object. + + https://bugzilla.gnome.org/show_bug.cgi?id=620593 + + gi/overrides/Gdk.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 44 insertions(+), 0 deletions(-) + +commit 0a9f1da052fd33dcef81d0e267fc7972f02c7888 +Author: Simon van der Linden +Date: Wed Jul 28 14:56:00 2010 +0200 + + Clean and improve the test infrastructure + + To run select tests, use for instance: + % make check TEST_NAMES='test_everything test_gi.TestConstant' + + It works with check.gdb and check.valgrind too. + + https://bugzilla.gnome.org/show_bug.cgi?id=625488 + + Makefile.am | 5 --- + tests/Makefile.am | 65 + ++++++++++++++++++++----------------------- + tests/common.py | 47 ------------------------------- + tests/runtests.py | 43 +++++++++++------------------ + tests/test_gcancellable.py | 4 +- + tests/test_gi.py | 3 -- + tests/test_gicon.py | 3 +- + tests/test_gio.py | 3 +- + tests/test_gobject.py | 3 +- + tests/test_gresolver.py | 4 +- + tests/test_gsocket.py | 4 ++- + tests/test_interface.py | 6 +++- + tests/test_mainloop.py | 11 +++----- + tests/test_signal.py | 4 ++- + tests/test_source.py | 4 +- + tests/test_subprocess.py | 5 +--- + tests/test_thread.py | 5 +++- + tests/test_unknown.py | 5 +++- + 18 files changed, 82 insertions(+), 142 deletions(-) + +commit 82f4cb5ebf5d992493b7a2f74cfd5f175e19eb76 +Author: Tomeu Vizoso +Date: Thu Jul 29 12:34:19 2010 +0200 + + Add some more transformations to pygi-convert.sh + + pygi-convert.sh | 37 +++++++++++++++++++++++++++++-------- + 1 files changed, 29 insertions(+), 8 deletions(-) + +commit de519adcd21947a0aef7932cdecb78cef200c85e +Author: Tomeu Vizoso +Date: Wed Jul 28 14:42:36 2010 +0200 + + Adapt to API changes: g_irepository_enumerate_versions + + gi/importer.py | 2 +- + gi/pygi-repository.c | 12 ++++++------ + 2 files changed, 7 insertions(+), 7 deletions(-) + +commit 01cd9abb43f93f9a57a5a05b6dc9560614e666e3 +Author: Tomeu Vizoso +Date: Wed Jul 28 12:26:48 2010 +0200 + + Add GValue<->GArgument marshalling for some more types + + gi/pygi-property.c | 37 ++++++++++++++++++++++++++++++++++++- + 1 files changed, 36 insertions(+), 1 deletions(-) + +commit ddffa70c3ee0e837070f390632bc692430f79171 +Author: Tomeu Vizoso +Date: Wed Jul 28 11:10:42 2010 +0200 + + Chain up with the non-introspection implementation for properties + if needed + + gobject/pygobject.c | 7 ++++++- + 1 files changed, 6 insertions(+), 1 deletions(-) + +commit 045433a1f8167205dc8eae613dcb8835d02c8916 +Author: Tomeu Vizoso +Date: Wed Jul 28 10:59:49 2010 +0200 + + Improve error reporting for missing attributes in introspection + modules + + gi/module.py | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +commit 6655a79b2f13fe417aefdf6aebab0f2d6162ba00 +Author: Tomeu Vizoso +Date: Tue Jul 27 21:52:49 2010 +0200 + + Implement getting and setting properties using introspection + information. + + This allows us to use information not present in GObject such as + transfer and element types. + + https://bugzilla.gnome.org/show_bug.cgi?id=620808 + + gi/Makefile.am | 2 + + gi/gimodule.c | 2 + + gi/pygi-argument.c | 2 + + gi/pygi-private.h | 1 + + gi/pygi-property.c | 226 + ++++++++++++++++++++++++++++++++++++++++++++++ + gi/pygi-property.h | 39 ++++++++ + gi/pygi.h | 41 +++++++++ + gobject/pygobject.c | 9 ++ + tests/test_everything.py | 19 ++++ + 9 files changed, 341 insertions(+), 0 deletions(-) + +commit 85f4572b3ffbfa364ebb2e470eab759edc557b36 +Author: Tomeu Vizoso +Date: Tue Jul 27 21:32:41 2010 +0200 + + Readd Gdk.Rectangle override for Gtk-2.0 + + gi/overrides/Gdk.py | 19 +++++++++++++++++++ + 1 files changed, 19 insertions(+), 0 deletions(-) + +commit 2082ee35e2a33f52bf1e8ec49cb4a43398e91989 +Author: Tomeu Vizoso +Date: Tue Jul 27 18:25:27 2010 +0200 + + Allow specifying a version when loading a typelib + + * gi/importer.py: Defer loading the typelib until first usage. + * gi/module.py: Load the typelib in IntrospectionModule(). + * gi/overrides/*.py: Adapt to API change. + * gi/pygi-repository.c: Add wrappers for g_irepository_enumerate and + g_irepository_get_version. + + gi/importer.py | 26 +++++---------- + gi/module.py | 58 + +++++++++++++++++++++++------------ + gi/overrides/GIMarshallingTests.py | 2 +- + gi/overrides/Gdk.py | 2 +- + gi/overrides/Gtk.py | 2 +- + gi/pygi-repository.c | 56 + ++++++++++++++++++++++++++++++++++- + 6 files changed, 105 insertions(+), 41 deletions(-) + +commit 6d7ed6c322234c240b1063a1dfaadd17157432a9 +Author: Jonathan Matthew +Date: Tue Jul 13 20:27:28 2010 +1000 + + treat GFreeFunc as equivalent to GDestroyNotify when scanning + callbacks + + https://bugzilla.gnome.org/show_bug.cgi?id=624232 + + gi/pygi-callbacks.c | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +commit 7e9cbd5601ad548b78d106bac1a1576d33b91c65 +Author: Simon van der Linden +Date: Mon Jul 26 17:00:23 2010 +0200 + + Don't use == to compare doubles, use <= and =>. + + This avoids inequality due to small precisions difference. + + https://bugzilla.gnome.org/show_bug.cgi?id=625326 + + tests/testhelpermodule.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 5ca2a41f16f4a5fcc3ab4d00bec46b077c7eb384 +Author: Tomeu Vizoso +Date: Thu Jul 8 11:36:12 2010 +0200 + + Allow passing ints as enum args + + https://bugzilla.gnome.org/show_bug.cgi?id=622584 + + gi/pygi-argument.c | 23 +++++++++++++++++++++-- + tests/test_gi.py | 6 ++++-- + 2 files changed, 25 insertions(+), 4 deletions(-) + +commit 890c3233f8a9f884b045a294bf0122bb3afcd54a +Author: Tomeu Vizoso +Date: Sun Jul 25 17:30:40 2010 +0100 + + Make error message less ambiguous + + https://bugzilla.gnome.org/show_bug.cgi?id=625095 + + gi/pygi-callbacks.c | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +commit 1162e436273ff8e9e4e24bd8ba74615fd4624753 +Author: John (J5) Palmieri +Date: Thu Jun 24 10:07:12 2010 -0400 + + fix passing in type names as a GType and add gtype unit tests + + * a simple call to pyg_type_from_object covers all the bases + * added unit tests to check for correct GType value passing + * fixed up tree override tests to also check different ways of + passing GTypes + + https://bugzilla.gnome.org/show_bug.cgi?id=622605 + + gi/pygi-argument.c | 8 +------- + tests/test_everything.py | 27 +++++++++++++++++++++++++++ + tests/test_overrides.py | 6 ++---- + 3 files changed, 30 insertions(+), 11 deletions(-) + +commit 8becd32fc042445d62b885bac12dac326b2dc1fa +Author: Tomeu Vizoso +Date: Mon Jul 26 11:54:47 2010 +0200 + + Increase a bit verbosity of tests so people know which test failed + + tests/runtests.py | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 3b3c63514f311592e6769a373d37a2bde7ea6b38 +Author: Tomeu Vizoso +Date: Thu Jul 15 15:17:53 2010 +0200 + + Actually add the files for GVariant foreign structs + + gi/pygi-foreign-gvariant.c | 63 + ++++++++++++++++++++++++++++++++++++++++++++ + gi/pygi-foreign-gvariant.h | 41 ++++++++++++++++++++++++++++ + 2 files changed, 104 insertions(+), 0 deletions(-) + +commit e65275bc57f345c111eb12a6b4476ff1ddc3bc24 +Author: Tomeu Vizoso +Date: Thu Jul 15 13:31:33 2010 +0200 + + Add foreign struct support for GVariant + + * gi/pygi-invoke.c: Wrap foreign structs returned by constructors + * gi/pygi-foreign.c: Register foreign support for GVariant + * gi/pygi-struct.c: properly release foreign structs + * gi/pygi-argument.c, gi/pygi-foreign-cairo.c, gi/pygi.h: Adapt to + API changes + * tests/test_everything.py: Add basic tests for GVariant + + https://bugzilla.gnome.org/show_bug.cgi?id=619501 + + gi/Makefile.am | 2 + + gi/pygi-argument.c | 2 +- + gi/pygi-foreign-cairo.c | 16 +++--- + gi/pygi-foreign.c | 107 + ++++++++++++++++++++++++++++----------------- + gi/pygi-foreign.h | 7 +-- + gi/pygi-invoke.c | 18 ++++---- + gi/pygi-struct.c | 10 ++++- + gi/pygi.h | 9 ++-- + tests/test_everything.py | 8 +++ + 9 files changed, 110 insertions(+), 69 deletions(-) + +commit 3b3bd4da3fbc993fa7f7cfb46ed4e67671c94cc0 +Author: Tomeu Vizoso +Date: Mon Jul 12 11:19:06 2010 +0200 + + Add HACKING to MANIFEST.in + + MANIFEST.in | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +commit 40bf08ff001b119c7daf709197005ef6480216c5 +Author: Tomeu Vizoso +Date: Mon Jul 12 11:18:04 2010 +0200 + + Add HACKING file with instructions for releasing + + HACKING | 14 ++++++++++++++ + 1 files changed, 14 insertions(+), 0 deletions(-) + +commit 3b9dffe7cc3820dfb84fd968fc604899601c5dc4 +Author: Tomeu Vizoso +Date: Mon Jul 12 11:09:58 2010 +0200 + + Post release version bump to 2.21.6 + + configure.ac | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + commit 42a5a0897b38156ae010c396ea254abf502f35de Author: Tomeu Vizoso -Date: Mon Jul 12 11:00:29 2010 +0200 +Date: Mon Jul 12 11:00:29 2010 +0200 Update NEWS and release PyGObject-2.21.5 @@ -9,7 +1433,7 @@ Date: Mon Jul 12 11:00:29 2010 +0200 commit 5857f25c1c6e25b79e6134558bd7151bc6c30ef7 Author: Tomeu Vizoso -Date: Mon Jul 12 11:00:20 2010 +0200 +Date: Mon Jul 12 11:00:20 2010 +0200 Pre-release version bump to 2.21.5 @@ -18,7 +1442,7 @@ Date: Mon Jul 12 11:00:20 2010 +0200 commit e500adc3ac19ef6f436809e5a8828ac7e8db28f6 Author: Florian Müllner -Date: Sat Jul 10 22:35:13 2010 +0200 +Date: Sat Jul 10 22:35:13 2010 +0200 Shut up some compiler warnings @@ -26,14 +1450,14 @@ Date: Sat Jul 10 22:35:13 2010 +0200 https://bugzilla.gnome.org/show_bug.cgi?id=624066 - gi/pygi-callbacks.c | 1 - - gi/pygi-closure.c | 2 +- - gi/pygi-invoke.c | 1 - + gi/pygi-callbacks.c | 1 - + gi/pygi-closure.c | 2 +- + gi/pygi-invoke.c | 1 - 3 files changed, 1 insertions(+), 3 deletions(-) commit 2efa18afbcc2fac1c90958535b2f80e6e730ee56 Author: =?UTF-8?q?Florian=20M=C3=BCllner?= -Date: Mon Jul 12 10:31:42 2010 +0200 +Date: Mon Jul 12 10:31:42 2010 +0200 Adjust to API break in GObject-Introspection @@ -49,39 +1473,39 @@ Date: Mon Jul 12 10:31:42 2010 +0200 https://bugzilla.gnome.org/show_bug.cgi?id=624065 - configure.ac | 2 +- - gi/importer.py | 7 ++- + configure.ac | 2 +- + gi/importer.py | 7 ++- gi/pygi-argument.c | 146 ---------------------------------------------------- - gi/pygi-closure.c | 10 ---- - gi/pygi-info.c | 37 ------------- - tests/test_gi.py | 21 -------- + gi/pygi-closure.c | 10 ---- + gi/pygi-info.c | 37 ------------- + tests/test_gi.py | 21 -------- 6 files changed, 5 insertions(+), 218 deletions(-) commit 27a417c71f8c122e46c7472663bb25c17413f103 Author: John (J5) Palmieri -Date: Thu Jul 8 16:01:25 2010 -0400 +Date: Thu Jul 8 16:01:25 2010 -0400 pass in the demo app so demos can use utility methods like requesting file paths - demos/gtk-demo/demos/Entry/entry_buffer.py | 2 +- + demos/gtk-demo/demos/Entry/entry_buffer.py | 2 +- demos/gtk-demo/demos/Entry/entry_completion.py | 2 +- - demos/gtk-demo/demos/appwindow.py | 13 +++++++++++-- - demos/gtk-demo/demos/assistant.py | 2 +- - demos/gtk-demo/demos/builder.py | 14 ++++++++++---- - demos/gtk-demo/demos/button_box.py | 2 +- - demos/gtk-demo/demos/clipboard.py | 8 +------- - demos/gtk-demo/demos/colorselector.py | 2 +- - demos/gtk-demo/demos/combobox.py | 8 +++++--- - demos/gtk-demo/demos/drawingarea.py | 2 +- - demos/gtk-demo/demos/test.py | 2 +- - demos/gtk-demo/gtk-demo.py | 6 +++--- + demos/gtk-demo/demos/appwindow.py | 13 +++++++++++-- + demos/gtk-demo/demos/assistant.py | 2 +- + demos/gtk-demo/demos/builder.py | 14 ++++++++++---- + demos/gtk-demo/demos/button_box.py | 2 +- + demos/gtk-demo/demos/clipboard.py | 8 +------- + demos/gtk-demo/demos/colorselector.py | 2 +- + demos/gtk-demo/demos/combobox.py | 8 +++++--- + demos/gtk-demo/demos/drawingarea.py | 2 +- + demos/gtk-demo/demos/test.py | 2 +- + demos/gtk-demo/gtk-demo.py | 6 +++--- 12 files changed, 37 insertions(+), 26 deletions(-) commit e7daae919c2c6ae35d3927f0006252aacd49ea86 Author: John (J5) Palmieri -Date: Thu Jul 8 15:38:07 2010 -0400 +Date: Thu Jul 8 15:38:07 2010 -0400 demo fixes to keep up with Gtk+ @@ -91,12 +1515,12 @@ Date: Thu Jul 8 15:38:07 2010 -0400 demos/gtk-demo/demos/appwindow.py | 10 +++++++--- demos/gtk-demo/demos/combobox.py | 24 ++++++++++++------------ - demos/gtk-demo/gtk-demo.py | 13 +++++-------- + demos/gtk-demo/gtk-demo.py | 13 +++++-------- 3 files changed, 24 insertions(+), 23 deletions(-) commit 3d9fd6391710cc33058394d6821e4d4e11f09b22 Author: John (J5) Palmieri -Date: Thu Jul 8 12:54:43 2010 -0400 +Date: Thu Jul 8 12:54:43 2010 -0400 override test fixes for new GTK+ annotations @@ -105,16 +1529,16 @@ Date: Thu Jul 8 12:54:43 2010 -0400 commit 7a400f8139b70ddfe7c949035e0851689951c647 Author: Ignacio Casal Quinteiro -Date: Thu Jul 8 12:42:25 2010 +0200 +Date: Thu Jul 8 12:42:25 2010 +0200 Fix warning. - gi/pygi-argument.c | 4 ++-- + gi/pygi-argument.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) commit 39fd0a85a3de06b1b877d1125f91036409886373 Author: John (J5) Palmieri -Date: Wed Jul 7 15:48:36 2010 -0400 +Date: Wed Jul 7 15:48:36 2010 -0400 fix up treeiter usage due to caller-allocates annotations in gtk+ @@ -123,13 +1547,13 @@ Date: Wed Jul 7 15:48:36 2010 -0400 handle the case where the parameter is followed by a regular in parameter - gi/overrides/Gtk.py | 7 +++---- + gi/overrides/Gtk.py | 7 +++---- tests/test_overrides.py | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) commit 4d970b75dc5c75c1bec04cb2954c9985b476070c Author: John (J5) Palmieri -Date: Tue Jul 6 17:50:10 2010 -0400 +Date: Tue Jul 6 17:50:10 2010 -0400 add entry completion demo @@ -139,45 +1563,45 @@ Date: Tue Jul 6 17:50:10 2010 -0400 commit f3531eaa1bfa4e01651d35cd587384d30a398ba8 Author: John (J5) Palmieri -Date: Tue Jul 6 17:49:18 2010 -0400 +Date: Tue Jul 6 17:49:18 2010 -0400 string changes - demos/gtk-demo/demos/Entry/entry_buffer.py | 4 ++-- + demos/gtk-demo/demos/Entry/entry_buffer.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) commit baf1e9bb550c7bf45e2ac0b70ba29c434ef1ccc6 Author: John (J5) Palmieri -Date: Tue Jul 6 17:27:04 2010 -0400 +Date: Tue Jul 6 17:27:04 2010 -0400 add the Entry demo directory and the entry_buffer demo - demos/gtk-demo/demos/Entry/entry_buffer.py | 73 + demos/gtk-demo/demos/Entry/entry_buffer.py | 73 ++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-) commit f2b1d222120f055bec9339cca55c9cc90f538c00 Author: John (J5) Palmieri -Date: Tue Jul 6 17:26:03 2010 -0400 +Date: Tue Jul 6 17:26:03 2010 -0400 fix loading of demo modules to support sub modules - demos/gtk-demo/gtk-demo.py | 9 +++++++-- + demos/gtk-demo/gtk-demo.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) commit 4f9390fb1892b13ab2ea00ed66c5000a40f09029 Author: John (J5) Palmieri -Date: Tue Jul 6 15:56:34 2010 -0400 +Date: Tue Jul 6 15:56:34 2010 -0400 add the ability to have demos in sub catagories - demos/gtk-demo/gtk-demo.py | 76 + demos/gtk-demo/gtk-demo.py | 76 +++++++++++++++++++++++++++++++------------- 1 files changed, 54 insertions(+), 22 deletions(-) commit dc2249a3ecf339008351316217191d0551ccc588 Author: Jose Aliste -Date: Mon Jul 5 14:36:59 2010 -0400 +Date: Mon Jul 5 14:36:59 2010 -0400 Add __name__ to DynamicModule class. @@ -188,7 +1612,7 @@ Date: Mon Jul 5 14:36:59 2010 -0400 commit 2357bca8d14539894b6bd0acfdc18d30b4bb4db6 Author: Ignacio Casal Quinteiro -Date: Mon Jul 5 16:11:07 2010 +0200 +Date: Mon Jul 5 16:11:07 2010 +0200 Do not override GdkRectangle. @@ -196,24 +1620,24 @@ Date: Mon Jul 5 16:11:07 2010 +0200 to override it anymore. - gi/overrides/Gdk.py | 19 ------------------- + gi/overrides/Gdk.py | 19 ------------------- 1 files changed, 0 insertions(+), 19 deletions(-) commit daca09dc2c2306d4fa82a68bbdd147d4b170a1e7 Author: Philip Withnall -Date: Tue Jun 29 16:37:36 2010 +0100 +Date: Tue Jun 29 16:37:36 2010 +0100 Add override for TreeModel implementing __len__() Closes: bgo#622882 - gi/overrides/Gtk.py | 11 +++++++++-- + gi/overrides/Gtk.py | 11 +++++++++-- tests/test_overrides.py | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) commit bb8adb7f02f0c5494df2cb6e535e44d23902e8f5 Author: Tomeu Vizoso -Date: Tue Jun 29 11:27:13 2010 +0200 +Date: Tue Jun 29 11:27:13 2010 +0200 Update NEWS and release PyGObject-2.21.4 @@ -222,60 +1646,60 @@ Date: Tue Jun 29 11:27:13 2010 +0200 commit 2d473ee17be4671244bb4a2a0953a21ccf2a0df6 Author: Tomeu Vizoso -Date: Tue Jun 29 10:55:03 2010 +0200 +Date: Tue Jun 29 10:55:03 2010 +0200 Remove files from the makefiles - gi/Makefile.am | 4 +--- - gobject/Makefile.am | 3 +-- + gi/Makefile.am | 4 +--- + gobject/Makefile.am | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) commit 89827314fd183eac07443c8e9d275ca9d4ce59df Author: Tomeu Vizoso -Date: Tue Jun 29 10:27:39 2010 +0200 +Date: Tue Jun 29 10:27:39 2010 +0200 Build the cairo shim as a python module so the _gi module stops linking to it https://bugzilla.gnome.org/show_bug.cgi?id=623021 - configure.ac | 2 + - gi/Makefile.am | 38 +++++++++----- - gi/gimodule.c | 8 +--- - gi/pygi-argument.c | 10 +--- + configure.ac | 2 + + gi/Makefile.am | 38 +++++++++----- + gi/gimodule.c | 8 +--- + gi/pygi-argument.c | 10 +--- gi/pygi-foreign-cairo.c | 56 ++++++++++++++++----- gi/pygi-foreign-cairo.h | 55 --------------------- - gi/pygi-foreign.c | 125 + gi/pygi-foreign.c | 125 ++++++++++++++++++++++++++++------------------- - gi/pygi-foreign.h | 31 +++++------ - gi/pygi.h | 40 +++++++++++++-- + gi/pygi-foreign.h | 31 +++++------ + gi/pygi.h | 40 +++++++++++++-- 9 files changed, 196 insertions(+), 169 deletions(-) commit a6a90551311bc64f037cbd442e13f70c30060871 Author: Tomeu Vizoso -Date: Mon Jun 28 14:20:43 2010 +0200 +Date: Mon Jun 28 14:20:43 2010 +0200 Remove pygi-external.h https://bugzilla.gnome.org/show_bug.cgi?id=623021 - gi/gimodule.c | 8 +++--- - gi/pygi-type.c | 4 +- - gi/pygi-type.h | 2 +- - gi/pygi.h | 54 +++++++++++++++---------------------- - gobject/Makefile.am | 6 ++++ - gobject/pygboxed.c | 2 +- - gobject/pygenum.c | 2 +- - gobject/pygflags.c | 2 +- + gi/gimodule.c | 8 +++--- + gi/pygi-type.c | 4 +- + gi/pygi-type.h | 2 +- + gi/pygi.h | 54 +++++++++++++++---------------------- + gobject/Makefile.am | 6 ++++ + gobject/pygboxed.c | 2 +- + gobject/pygenum.c | 2 +- + gobject/pygflags.c | 2 +- gobject/pygi-external.h | 67 ----------------------------------------------- - gobject/pygobject.c | 2 +- - gobject/pygpointer.c | 2 +- + gobject/pygobject.c | 2 +- + gobject/pygpointer.c | 2 +- 11 files changed, 40 insertions(+), 111 deletions(-) commit 8b3a3baacb45cb3f9112f7597607602fa89c6634 Author: Tomeu Vizoso -Date: Fri Jun 25 13:54:57 2010 +0200 +Date: Fri Jun 25 13:54:57 2010 +0200 Revert "correctly handle floating objects in gtk" diff --git a/MANIFEST.in b/MANIFEST.in index 002138a..3781c83 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include ChangeLog AUTHORS COPYING NEWS README +include ChangeLog AUTHORS COPYING NEWS README HACKING include MANIFEST.in include gobject/pygobject.h gobject/pygobject-private.h include pygtk.py pygobject-2.0.pc.in diff --git a/Makefile.am b/Makefile.am index 94bcf8e..6fe43c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -128,11 +128,6 @@ dist-hook: $(BUILT_EXTRA_DIST) check.gdb: cd tests && $(MAKE) check.gdb -%.gdb: - cd tests && $(MAKE) $*.gdb - check.valgrind: cd tests && $(MAKE) check.valgrind -%.valgrind: - cd tests && $(MAKE) $*.valgrind diff --git a/Makefile.in b/Makefile.in index ecd83fd..0692461 100644 --- a/Makefile.in +++ b/Makefile.in @@ -183,6 +183,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ @@ -1096,15 +1097,9 @@ dist-hook: $(BUILT_EXTRA_DIST) check.gdb: cd tests && $(MAKE) check.gdb -%.gdb: - cd tests && $(MAKE) $*.gdb - check.valgrind: cd tests && $(MAKE) check.valgrind -%.valgrind: - cd tests && $(MAKE) $*.valgrind - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/NEWS b/NEWS index c6a8b41..fc43753 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,96 @@ +2.26.0 24-Sep-2010 + - Wrap g_get_system_{config,data}_dirs () (John Strowers) + - fixed make check and make dist (John (J5) Palmieri) + - Disable GI tests when introspection disabled (John Stowers) + - Wrap g_uri_list_extract_uris. Fixes bug #584431 (Tomeu Vizoso) + - Fix a few uses of TRUE and FALSE in the docs (Paul Bolle) + - pygi: always free the invocation_state struct (Damien Caliste) + - Start implementing something equivalent to g_variant_new (Tomeu Vizoso) + - fixed typo - missing comma in glib.option module (John (J5) Palmieri) + - add checks so we can compile under python 3 by setting PYTHON=python3 (John (J5) Palmieri) + - Rename static methods as functions (Tomeu Vizoso) + - fix a couple of compiler warnings (John (J5) Palmieri) + - remove unused code (John (J5) Palmieri) + - Check the type of the instance object (John (J5) Palmieri) + - include the correct pycairo version (John (J5) Palmieri) + - Use PyMapping_Keys to determine if an object is a dict (py3k fix) (John (J5) Palmieri) + - fix handling of UINT64 and INT64 arguments in py3k (John (J5) Palmieri) + - properly handle ulongs properties in py3k (John (J5) Palmieri) + - Specify encoding of tests/test_gi.py (Tomeu Vizoso) + - use actual unicode in the tests on py3k, not the byte representation (John (J5) Palmieri) + - s/METH_KEYWORDS/METH_VARARGS|METH_KEYWORDS/ when defining object methods (John (J5) Palmieri) + - fix subclassing PyLong by calling __new__ correctly (John (J5) Palmieri) + - minor py3k fixups for python modules (John (J5) Palmieri) + - minor fixes in tests for py3k compat (John (J5) Palmieri) + - compilation: Fix syntax error (Colin Walters) + - Add missing file (Tomeu Vizoso) + - Add override for GLib.Variant.new_tuple (Tomeu Vizoso) + - fix for changes in the gi test libraries (John (J5) Palmieri) + - Gtk.DialogFlags.NO_SEPARATOR has been removed in Gtk 3.0 (John (J5) Palmieri) + - no need to offset arg positions when is_method is true (John (J5) Palmieri) + - gi: Add support for more property types (Tomeu Vizoso) + - use PyObject_SetAttrString, not PyDict_SetItemString when setting __gtype__ (John (J5) Palmieri) + - Rename GArgument to GIArgument (Tomeu Vizoso) + - fix up tests so they run in py3k (John (J5) Palmieri) + - tests: Port to new introspection tests (Colin Walters) + - we need to specify tp_hash since we overide tp_richcompare (John (J5) Palmieri) + - working enum/flags/pid subclasses of long (John Ehresman) + - make vfuncs work in py3k (John (J5) Palmieri) + - make cairo module compile in py3k (John (J5) Palmieri) + - fix exceptions so they work in python 3.x (John (J5) Palmieri) + - make the gi module compile under 3.x (John (J5) Palmieri) + - fix up testshelper module so it compiles in python 3.x (John (J5) Palmieri) + - convert to using PYGLIB_DEFINE_TYPE for module objects (John (J5) Palmieri) + - some more p3k PyString and PyInt eradication in GI (John (J5) Palmieri) + - pyglib: Fix typo (Leo Singer) (Tomeu Vizoso) + - Add defines for size_t and ssize_t conversion functions (Gustavo Noronha Silva) + - pyglib: Fix a compiler warning (Colin Walters) + - Don't force gtk 2.0 (Tomeu Vizoso) + - Fix some ref leaks in hook_up_vfunc_implementation() (Steve Frécinaux) + - handle strings correctly in gio (John (J5) Palmieri) + - make giomodule compile under py3k (John (J5) Palmieri) + - for py3k we need to do some more processing to get bytes from a unicode string (John (J5) Palmieri) + - use Bytes instead of Unicode when reading io (John (J5) Palmieri) + - prefix compat macros with PYGLIB (John (J5) Palmieri) + - Gtk.Button unit tests (John (J5) Palmieri) + - [Gtk] Add overrides for Button (Johan Dahlin) + - Make Cairo an optional dependency (Simon van der Linden) + - Don't import again PyGObject (John Ralls) (Tomeu Vizoso) + - move to using richcompare slot instead of compare (John (J5) Palmieri) + - Replace autogen.sh by a newer version (Simon van der Linden) + - Fix some warnings (Simon van der Linden) + - Fix caller-allocates emergency free. (Simon van der Linden) + - Remove useless checks. (Simon van der Linden) + - Call valgrind with G_SLICE=always-malloc G_DEBUG=gc-friendly (Tomeu Vizoso) + - Fix some warnings. (Ignacio Casal Quinteiro) + - Add myself as a maintainer (Simon van der Linden) + - Properly allocate boxed structs that are (caller-allocates) (Tomeu Vizoso) + - override gdk.Event to return attribute from the proper event object (Toms Baugis) + - check if z# needs an int or Py_ssize_t (John (J5) Palmieri) + - make sure we parse parameters to python object vars not glib vars (John (J5) Palmieri) + - Make an example and a demo work out of the box (Paul Bolle) + - make sure caller allocated structs are freed when they go out of scope (John (J5) Palmieri) + - Revert "override gdk.Event to return attribute from the proper event object." (Tomeu Vizoso) + - PyGI: properly quit cairo-demo (Paul Bolle) + - override gdk.Event to return attribute from the proper event object. (Toms Baugis) + - Clean and improve the test infrastructure (Simon van der Linden) + - Add some more transformations to pygi-convert.sh (Tomeu Vizoso) + - Adapt to API changes: g_irepository_enumerate_versions (Tomeu Vizoso) + - Add GValue<->GArgument marshalling for some more types (Tomeu Vizoso) + - Chain up with the non-introspection implementation for properties if needed (Tomeu Vizoso) + - Improve error reporting for missing attributes in introspection modules (Tomeu Vizoso) + - Implement getting and setting properties using introspection information. (Tomeu Vizoso) + - Readd Gdk.Rectangle override for Gtk-2.0 (Tomeu Vizoso) + - Allow specifying a version when loading a typelib (Tomeu Vizoso) + - treat GFreeFunc as equivalent to GDestroyNotify when scanning callbacks (Jonathan Matthew) + - Don't use == to compare doubles, use <= and =>. (Simon van der Linden) + - Allow passing ints as enum args (Tomeu Vizoso) + - Make error message less ambiguous (Tomeu Vizoso) + - fix passing in type names as a GType and add gtype unit tests (John (J5) Palmieri) + - Increase a bit verbosity of tests so people know which test failed (Tomeu Vizoso) + - Actually add the files for GVariant foreign structs (Tomeu Vizoso) + - Add foreign struct support for GVariant (Tomeu Vizoso) + 2.21.5 12-Jul-2010 - Shut up some compiler warnings (Florian Müllner) - Adjust to API break in GObject-Introspection (Florian Müllner) diff --git a/PKG-INFO b/PKG-INFO index db437e1..14b46bb 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: PyGObject -Version: 2.21.5 +Version: 2.26.0 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/2.21/pygobject-2.21.5.tar.gz +Download-url: ftp://ftp.gnome.org/pub/GNOME/sources/pygobject/2.26/pygobject-2.26.0.tar.gz Description: Python bindings for GLib, GObject and GIO Platform: POSIX, Windows Classifier: Development Status :: 5 - Production/Stable diff --git a/aclocal.m4 b/aclocal.m4 index cd9551e..4a87bab 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -19,1662 +19,1662 @@ 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'.])]) -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_AUTOMAKE_VERSION(VERSION) -# ---------------------------- -# Automake X.Y traces this macro to ensure aclocal.m4 has been -# generated from the m4 files accompanying Automake X.Y. -# (This private macro should not be called outside this file.) -AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' -dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to -dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.1], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl -]) - -# _AM_AUTOCONF_VERSION(VERSION) -# ----------------------------- -# aclocal traces this macro to find the Autoconf version. -# This is a private macro too. Using m4_define simplifies -# the logic in aclocal, which can simply ignore this definition. -m4_define([_AM_AUTOCONF_VERSION], []) - -# AM_SET_CURRENT_AUTOMAKE_VERSION -# ------------------------------- -# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. -# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. -AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) - -# AM_AUX_DIR_EXPAND -*- Autoconf -*- - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. -# -# Of course, Automake must honor this variable whenever it calls a -# tool from the auxiliary directory. The problem is that $srcdir (and -# therefore $ac_aux_dir as well) can be either absolute or relative, -# depending on how configure is run. This is pretty annoying, since -# it makes $ac_aux_dir quite unusable in subdirectories: in the top -# source directory, any form will work fine, but in subdirectories a -# relative path needs to be adjusted first. -# -# $ac_aux_dir/missing -# fails when called from a subdirectory if $ac_aux_dir is relative -# $top_srcdir/$ac_aux_dir/missing -# fails if $ac_aux_dir is absolute, -# fails when called from a subdirectory in a VPATH build with -# a relative $ac_aux_dir -# -# The reason of the latter failure is that $top_srcdir and $ac_aux_dir -# are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you -# start a VPATH build or use an absolute $srcdir. -# -# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, -# iff we strip the leading $srcdir from $ac_aux_dir. That would be: -# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` -# and then we would define $MISSING as -# MISSING="\${SHELL} $am_aux_dir/missing" -# This will work as long as MISSING is not called from configure, because -# unfortunately $(top_srcdir) has no meaning in configure. -# However there are other variables, like CC, which are often used in -# configure, and could therefore not use this "fixed" $ac_aux_dir. -# -# Another solution, used here, is to always expand $ac_aux_dir to an -# absolute PATH. The drawback is that using absolute paths prevent a -# configured tree to be moved without reconfiguration. - -AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` -]) +# 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) -# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. + 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 -# serial 4 + PKG_PROG_PKG_CONFIG([0.16]) -# This was merged into AC_PROG_CC in Autoconf. + no_glib="" -AU_DEFUN([AM_PROG_CC_STDC], -[AC_PROG_CC -AC_DIAGNOSE([obsolete], [$0: - your code should no longer depend upon `am_cv_prog_cc_stdc', but upon - `ac_cv_prog_cc_stdc'. Remove this warning and the assignment when - you adjust the code. You can also remove the above call to - AC_PROG_CC if you already called it elsewhere.]) -am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc -]) -AU_DEFUN([fp_PROG_CC_STDC]) + if test "x$PKG_CONFIG" = x ; then + no_glib=yes + PKG_CONFIG=no + fi -# AM_CONDITIONAL -*- Autoconf -*- + min_glib_version=ifelse([$1], ,2.0.0,$1) + AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. + 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 -# serial 9 + if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then + : + else + no_glib=yes + fi + fi -# AM_CONDITIONAL(NAME, SHELL-CONDITION) -# ------------------------------------- -# Define a conditional. -AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl -AC_SUBST([$1_TRUE])dnl -AC_SUBST([$1_FALSE])dnl -_AM_SUBST_NOTMAKE([$1_TRUE])dnl -_AM_SUBST_NOTMAKE([$1_FALSE])dnl -m4_define([_AM_COND_VALUE_$1], [$2])dnl -if $2; then - $1_TRUE= - $1_FALSE='#' -else - $1_TRUE='#' - $1_FALSE= -fi -AC_CONFIG_COMMANDS_PRE( -[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then - AC_MSG_ERROR([[conditional "$1" was never defined. -Usually this means the macro was only invoked conditionally.]]) -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` -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. + 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 +#include +#include -# serial 10 +int +main () +{ + int major, minor, micro; + char *tmp_version; -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be -# written in clear, in which case automake, when reading aclocal.m4, -# will think it sees a *use*, and therefore will trigger all it's -# C support machinery. Also note that it means that autoscan, seeing -# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + fclose (fopen ("conf.glibtest", "w")); + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } -# _AM_DEPENDENCIES(NAME) -# ---------------------- -# See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". -# We try a few techniques and use that to set a single cache variable. -# -# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was -# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular -# dependency, and given that the user is not expected to run this macro, -# just rely on AC_PROG_CC. -AC_DEFUN([_AM_DEPENDENCIES], -[AC_REQUIRE([AM_SET_DEPDIR])dnl -AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl -AC_REQUIRE([AM_MAKE_INCLUDE])dnl -AC_REQUIRE([AM_DEP_TRACK])dnl + 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 (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. 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 +#include +], [ 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="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + AC_SUBST(GLIB_GENMARSHAL) + AC_SUBST(GOBJECT_QUERY) + AC_SUBST(GLIB_MKENUMS) + rm -f conf.glibtest +]) -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# 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. -AC_CACHE_CHECK([dependency style of $depcc], - [am_cv_$1_dependencies_compiler_type], -[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then - # We make a subdir and do the tests there. Otherwise we can end up - # making bogus files that we don't know about and never remove. For - # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. - mkdir conftest.dir - # Copy depcomp to subdir because otherwise we won't find it if we're - # using a relative directory. - cp "$am_depcomp" conftest.dir - cd conftest.dir - # We will build objects and dependencies in a subdirectory because - # it helps to detect inapplicable dependency modes. For instance - # both Tru64's cc and ICC support -MD to output dependencies as a - # side effect of compilation, but ICC will put the dependencies in - # the current directory while Tru64 will put them in the object - # directory. - mkdir sub +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +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 - am_cv_$1_dependencies_compiler_type=none - if test "$am_compiler_list" = ""; then - am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` - fi - am__universal=false - m4_case([$1], [CC], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac], - [CXX], - [case " $depcc " in #( - *\ -arch\ *\ -arch\ *) am__universal=true ;; - esac]) +# 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. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure 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_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) - for depmode in $am_compiler_list; do - # Setup a source with many dependencies, because some compilers - # like to wrap large dependency lists on column 80 (with \), and - # we should not choose a depcomp mode which is confused by this. - # - # We need to recreate these files for each test, as the compiler may - # overwrite some of them when testing with obscure command lines. - # This happens at least with the AIX C compiler. - : > sub/conftest.c - for i in 1 2 3 4 5 6; do - echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h - done - echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with `-c' and `-o' for the sake of the "dashmstdout" - # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs - am__obj=sub/conftest.${OBJEXT-o} - am__minus_obj="-o $am__obj" - case $depmode in - gcc) - # This depmode causes a compiler race in universal mode. - test "$am__universal" = false || continue - ;; - nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested - if test "x$enable_dependency_tracking" = xyes; then - continue - else - break - fi - ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has - # not run yet. These depmodes are late enough in the game, and - # so weak that their functioning should not be impacted. - am__obj=conftest.${OBJEXT-o} - am__minus_obj= - ;; - none) break ;; - esac - if depmode=$depmode \ - source=sub/conftest.c object=$am__obj \ - depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ - $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ - >/dev/null 2>conftest.err && - grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && - grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && - grep $am__obj sub/conftest.Po > /dev/null 2>&1 && - ${MAKE-make} -s -f confmf > /dev/null 2>&1; then - # icc doesn't choke on unknown options, it will just issue warnings - # or remarks (even with -Werror). So we grep stderr for any message - # that says an option was ignored or not supported. - # When given -MP, icc 7.0 and 7.1 complain thusly: - # icc: Command line warning: ignoring option '-M'; no argument required - # The diagnosis changed in icc 8.0: - # icc: Command line remark: option '-MP' not supported - if (grep 'ignoring option' conftest.err || - grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else - am_cv_$1_dependencies_compiler_type=$depmode - break - fi - fi - done +# _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`], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG - cd .. - rm -rf conftest.dir +# _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 - am_cv_$1_dependencies_compiler_type=none -fi -]) -AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) -AM_CONDITIONAL([am__fastdep$1], [ - test "x$enable_dependency_tracking" != xno \ - && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) -]) + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED -# AM_SET_DEPDIR -# ------------- -# Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES -AC_DEFUN([AM_SET_DEPDIR], -[AC_REQUIRE([AM_SET_LEADING_DOT])dnl -AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl -]) +# 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.]) -# AM_DEP_TRACK -# ------------ -AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi -AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) -AC_SUBST([AMDEPBACKSLASH])dnl -_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl -]) +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD -# Generate code to set up dependency tracking. -*- Autoconf -*- + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +$$1_PKG_ERRORS -#serial 5 +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -# _AM_OUTPUT_DEPENDENCY_COMMANDS -# ------------------------------ -AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], -[{ - # Autoconf 2.62 quotes --file arguments for eval, but not when files - # are listed without --file. Let's play safe and only enable the eval - # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac - shift - for mf - do - # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line - # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done - done -} -])# _AM_OUTPUT_DEPENDENCY_COMMANDS +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[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 -# AM_OUTPUT_DEPENDENCY_COMMANDS -# ----------------------------- -# This macro should only be invoked once -- use via AC_REQUIRE. -# -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. -AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], -[AC_CONFIG_COMMANDS([depfiles], - [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 8 +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) -# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) -# Do all the work for Automake. -*- Autoconf -*- +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 16 - -# This macro actually does too much. Some checks are only needed if -# your package does certain things. But this isn't really a big deal. - -# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) -# AM_INIT_AUTOMAKE([OPTIONS]) -# ----------------------------------------------- -# The call with PACKAGE and VERSION arguments is the old style -# call (pre autoconf-2.50), which is being phased out. PACKAGE -# and VERSION should now be passed to AC_INIT and removed from -# the call to AM_INIT_AUTOMAKE. -# We support both call styles for the transition. After -# the next Automake release, Autoconf can make the AC_INIT -# arguments mandatory, and then we can depend on a new Autoconf -# release and drop the old call support. -AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl -dnl Autoconf wants to disallow AM_ names. We explicitly allow -dnl the ones we care about. -m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl -AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl -AC_REQUIRE([AC_PROG_INSTALL])dnl -if test "`cd $srcdir && pwd`" != "`pwd`"; then - # Use -I$(srcdir) only when $(srcdir) != ., so that make's output - # is not polluted with repeated "-I." - AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl - # test to see if srcdir already configured - if test -f $srcdir/config.status; then - AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) - fi -fi - -# test whether we have cygpath -if test -z "$CYGPATH_W"; then - if (cygpath --version) >/dev/null 2>/dev/null; then - CYGPATH_W='cygpath -w' - else - CYGPATH_W=echo - fi -fi -AC_SUBST([CYGPATH_W]) +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. -# Define the identity of the package. -dnl Distinguish between old-style and new-style calls. -m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl - AC_SUBST([PACKAGE], [$1])dnl - AC_SUBST([VERSION], [$2])], -[_AM_SET_OPTIONS([$1])dnl -dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, - [m4_fatal([AC_INIT should be called with package and version arguments])])dnl - AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl - AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) -_AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl -# Some tools Automake needs. -AC_REQUIRE([AM_SANITY_CHECK])dnl -AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) -AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -AC_REQUIRE([AC_PROG_AWK])dnl -AC_REQUIRE([AC_PROG_MAKE_SET])dnl -AC_REQUIRE([AM_SET_LEADING_DOT])dnl -_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], - [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], - [_AM_PROG_TAR([v7])])]) -_AM_IF_OPTION([no-dependencies],, -[AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl -AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl -]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. -AC_CONFIG_COMMANDS_PRE(dnl -[m4_provide_if([_AM_COMPILER_EXEEXT], - [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) +# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not -dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further -dnl mangled by Autoconf and run in a shell conditional statement. -m4_define([_AC_COMPILER_EXEEXT], -m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) +# serial 4 +# This was merged into AC_PROG_CC in Autoconf. -# When config.status generates a header, we must update the stamp-h file. -# This file resides in the same directory as the config header -# that is generated. The stamp files are numbered to have different names. +AU_DEFUN([AM_PROG_CC_STDC], +[AC_PROG_CC +AC_DIAGNOSE([obsolete], [$0: + your code should no longer depend upon `am_cv_prog_cc_stdc', but upon + `ac_cv_prog_cc_stdc'. Remove this warning and the assignment when + you adjust the code. You can also remove the above call to + AC_PROG_CC if you already called it elsewhere.]) +am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc +]) +AU_DEFUN([fp_PROG_CC_STDC]) -# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the -# loop where config.status creates the headers, so we can generate -# our stamp files there. -AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], -[# Compute $1's index in $config_headers. -_am_arg=$1 -_am_stamp_count=1 -for _am_header in $config_headers :; do - case $_am_header in - $_am_arg | $_am_arg:* ) - break ;; - * ) - _am_stamp_count=`expr $_am_stamp_count + 1` ;; - esac -done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) +# AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_PROG_INSTALL_SH -# ------------------ -# Define $install_sh. -AC_DEFUN([AM_PROG_INSTALL_SH], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; - *) - install_sh="\${SHELL} $am_aux_dir/install-sh" - esac +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= fi -AC_SUBST(install_sh)]) +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 +# serial 10 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done -# Check whether the underlying file-system supports filenames -# with a leading dot. For instance MS-DOS doesn't. -AC_DEFUN([AM_SET_LEADING_DOT], -[rm -rf .tst 2>/dev/null -mkdir .tst 2>/dev/null -if test -d .tst; then - am__leading_dot=. + cd .. + rm -rf conftest.dir else - am__leading_dot=_ + am_cv_$1_dependencies_compiler_type=none fi -rmdir .tst 2>/dev/null -AC_SUBST([am__leading_dot])]) - -# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- -# From Jim Meyering - -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 5 - -# AM_MAINTAINER_MODE([DEFAULT-MODE]) -# ---------------------------------- -# Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user -# can override the default with the --enable/--disable switch. -AC_DEFUN([AM_MAINTAINER_MODE], -[m4_case(m4_default([$1], [disable]), - [enable], [m4_define([am_maintainer_other], [disable])], - [disable], [m4_define([am_maintainer_other], [enable])], - [m4_define([am_maintainer_other], [enable]) - m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) - dnl maintainer-mode's default is 'disable' unless 'enable' is passed - AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) - AC_MSG_RESULT([$USE_MAINTAINER_MODE]) - AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) - MAINT=$MAINTAINER_MODE_TRUE - AC_SUBST([MAINT])dnl -] -) - -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - -# Check to see how 'make' treats includes. -*- Autoconf -*- - -# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) -# serial 4 -# AM_MAKE_INCLUDE() -# ----------------- -# Check to see how make treats includes. -AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo this is the am__doit target -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) -# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 6 -# AM_PROG_CC_C_O -# -------------- -# Like AC_PROG_CC_C_O, but changed for automake. -AC_DEFUN([AM_PROG_CC_C_O], -[AC_REQUIRE([AC_PROG_CC_C_O])dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -# FIXME: we rely on the cache variable name because -# there is no other way. -set dummy $CC -am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` -eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o -if test "$am_t" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' fi -dnl Make sure AC_PROG_CC is never called again, or it will override our -dnl setting of CC. -m4_define([AC_PROG_CC], - [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) -# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- +# Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 +#serial 5 -# AM_MISSING_PROG(NAME, PROGRAM) +# _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ -AC_DEFUN([AM_MISSING_PROG], -[AC_REQUIRE([AM_MISSING_HAS_RUN]) -$1=${$1-"${am_missing_run}$2"} -AC_SUBST($1)]) - - -# AM_MISSING_HAS_RUN -# ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. -AC_DEFUN([AM_MISSING_HAS_RUN], -[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([missing])dnl -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; esac -fi -# Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " -else - am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) -fi + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) +# serial 8 -# Helper functions for option handling. -*- Autoconf -*- +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 +# serial 16 -# _AM_MANGLE_OPTION(NAME) -# ----------------------- -AC_DEFUN([_AM_MANGLE_OPTION], -[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. -# _AM_SET_OPTION(NAME) -# ------------------------------ -# Set option NAME. Presently that only means defining a flag for this option. -AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi -# _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- -# OPTIONS is a space-separated list of Automake options. -AC_DEFUN([_AM_SET_OPTIONS], -[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) -# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) -# ------------------------------------------- -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -AC_DEFUN([_AM_IF_OPTION], -[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl -# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# --------------------------------------------------------------------------- -# Adds support for distributing Python modules and packages. To -# install modules, copy them to $(pythondir), using the python_PYTHON -# automake variable. To install a package with the same name as the -# automake package, install to $(pkgpythondir), or use the -# pkgpython_PYTHON automake variable. -# -# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as -# locations to install python extension modules (shared libraries). -# Another macro is required to find the appropriate flags to compile -# extension modules. -# -# If your package is configured with a different prefix to python, -# users will have to add the install directory to the PYTHONPATH -# environment variable, or create a .pth file (see the python -# documentation for details). -# -# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will -# cause an error if the version of python installed on the system -# doesn't meet the requirement. MINIMUM-VERSION should consist of -# numbers and dots only. -AC_DEFUN([AM_PATH_PYTHON], - [ - dnl Find a Python interpreter. Python versions prior to 2.0 are not - dnl supported. (2.0 was released on October 16, 2000). - m4_define_default([_AM_PYTHON_INTERPRETER_LIST], - [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl -python2.1 python2.0]) +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) - m4_if([$1],[],[ - dnl No version check is needed. - # Find any Python interpreter. - if test -z "$PYTHON"; then - AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) - fi - am_display_PYTHON=python - ], [ - dnl A version check is needed. - if test -n "$PYTHON"; then - # If the user set $PYTHON, use it and don't search something else. - AC_MSG_CHECKING([whether $PYTHON version >= $1]) - AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR(too old)]) - am_display_PYTHON=$PYTHON - else - # Otherwise, try each interpreter until we find one that satisfies - # VERSION. - AC_CACHE_CHECK([for a Python interpreter with version >= $1], - [am_cv_pathless_PYTHON],[ - for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do - test "$am_cv_pathless_PYTHON" = none && break - AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) - done]) - # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. - if test "$am_cv_pathless_PYTHON" = none; then - PYTHON=: - else - AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) - fi - am_display_PYTHON=$am_cv_pathless_PYTHON - fi - ]) +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - if test "$PYTHON" = :; then - dnl Run any user-specified action, or abort. - m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) - else - dnl Query Python for its version number. Getting [:3] seems to be - dnl the best way to do this; it's what "site.py" does in the standard - dnl library. +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. - AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], - [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) - AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) - dnl Use the values of $prefix and $exec_prefix for the corresponding - dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made - dnl distinct variables so they can be overridden if need be. However, - dnl general consensus is that you shouldn't need this ability. +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - AC_SUBST([PYTHON_PREFIX], ['${prefix}']) - AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) - dnl At times (like when building shared libraries) you may want - dnl to know which OS platform Python thinks this is. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], - [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) - AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) +# serial 2 +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) - dnl Set up 4 directories: +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering - dnl pythondir -- where to install python scripts. This is the - dnl site-packages directory, not the python standard library - dnl directory like in previous automake betas. This behavior - dnl is more consistent with lispdir.m4 for example. - dnl Query distutils for this directory. distutils does not exist in - dnl Python 1.5, so we fall back to the hardcoded directory if it - dnl doesn't work. - AC_CACHE_CHECK([for $am_display_PYTHON script directory], - [am_cv_python_pythondir], - [if test "x$prefix" = xNONE - then - am_py_prefix=$ac_default_prefix - else - am_py_prefix=$prefix - fi - am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null || - echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"` - case $am_cv_python_pythondir in - $am_py_prefix*) - am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` - am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` - ;; - *) - case $am_py_prefix in - /usr|/System*) ;; - *) - am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages - ;; - esac - ;; - esac - ]) - AC_SUBST([pythondir], [$am_cv_python_pythondir]) +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - dnl pkgpythondir -- $PACKAGE directory under pythondir. Was - dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is - dnl more consistent with the rest of automake. +# serial 5 - AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) - dnl pyexecdir -- directory for installing python extension modules - dnl (shared libraries) - dnl Query distutils for this directory. distutils does not exist in - dnl Python 1.5, so we fall back to the hardcoded directory if it - dnl doesn't work. - AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], - [am_cv_python_pyexecdir], - [if test "x$exec_prefix" = xNONE - then - am_py_exec_prefix=$am_py_prefix - else - am_py_exec_prefix=$exec_prefix - fi - am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null || - echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"` - case $am_cv_python_pyexecdir in - $am_py_exec_prefix*) - am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` - am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` - ;; - *) - case $am_py_exec_prefix in - /usr|/System*) ;; - *) - am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages - ;; - esac - ;; - esac - ]) - AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) +# Check to see how 'make' treats includes. -*- Autoconf -*- - AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - dnl Run any user-specified action. - $2 - fi +# serial 4 +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf ]) - -# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# --------------------------------------------------------------------------- -# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. -# Run ACTION-IF-FALSE otherwise. -# This test uses sys.hexversion instead of the string equivalent (first -# word of sys.version), in order to cope with versions such as 2.2c1. -# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). -AC_DEFUN([AM_PYTHON_CHECK_VERSION], - [prog="import sys -# split strings by '.' and convert to numeric. Append some zeros -# because we need at least 4 digits for the hex conversion. -# map returns an iterator in Python 3.0 and a list in 2.x -minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] -minverhex = 0 -# xrange is not present in Python 3.0 and range returns an iterator -for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] -sys.exit(sys.hexversion < minverhex)" - AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) - -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_RUN_LOG(COMMAND) -# ------------------- -# Run COMMAND, save the exit status in ac_status, and log it. -# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) -AC_DEFUN([AM_RUN_LOG], -[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD - ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - (exit $ac_status); }]) +# serial 6 + +# AM_PROG_CC_C_O +# -------------- +# Like AC_PROG_CC_C_O, but changed for automake. +AC_DEFUN([AM_PROG_CC_C_O], +[AC_REQUIRE([AC_PROG_CC_C_O])dnl +AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +# FIXME: we rely on the cache variable name because +# there is no other way. +set dummy $CC +am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` +eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o +if test "$am_t" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +dnl Make sure AC_PROG_CC is never called again, or it will override our +dnl setting of CC. +m4_define([AC_PROG_CC], + [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) +]) -# Check to make sure that the build environment is sane. -*- Autoconf -*- +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - -# AM_SANITY_CHECK -# --------------- -AC_DEFUN([AM_SANITY_CHECK], -[AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file -# Reject unsafe characters in $srcdir or the absolute working directory -# name. Accept space and tab only in the latter. -am_lf=' -' -case `pwd` in - *[[\\\"\#\$\&\'\`$am_lf]]*) - AC_MSG_ERROR([unsafe absolute working directory name]);; -esac -case $srcdir in - *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; -esac +# serial 6 -# Do `set' in a subshell so we don't clobber the current shell's -# arguments. Must try -L first in case configure is actually a -# symlink; some systems play weird games with the mod time of symlinks -# (eg FreeBSD returns the mod time of the symlink's containing -# directory). -if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi - test "$[2]" = conftest.file - ) -then - # Ok. - : +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " else - AC_MSG_ERROR([newly created file is older than distributed files! -Check your system clock]) + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) fi -AC_MSG_RESULT(yes)]) +]) -# Copyright (C) 2009 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 1 - -# AM_SILENT_RULES([DEFAULT]) -# -------------------------- -# Enable less verbose build rules; with the default set to DEFAULT -# (`yes' being less verbose, `no' or empty being verbose). -AC_DEFUN([AM_SILENT_RULES], -[AC_ARG_ENABLE([silent-rules], -[ --enable-silent-rules less verbose build output (undo: `make V=1') - --disable-silent-rules verbose build output (undo: `make V=0')]) -case $enable_silent_rules in -yes) AM_DEFAULT_VERBOSITY=0;; -no) AM_DEFAULT_VERBOSITY=1;; -*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac -AC_SUBST([AM_DEFAULT_VERBOSITY])dnl -AM_BACKSLASH='\' -AC_SUBST([AM_BACKSLASH])dnl -_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_PROG_INSTALL_STRIP -# --------------------- -# One issue with vendor `install' (even GNU) is that you can't -# specify the program used to strip binaries. This is especially -# annoying in cross-compiling environments, where the build's strip -# is unlikely to handle the host's binaries. -# Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize -# STRIPPROG with the value of the STRIP variable (set by the user). -AC_DEFUN([AM_PROG_INSTALL_STRIP], -[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right -# tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. -if test "$cross_compiling" != no; then - AC_CHECK_TOOL([STRIP], [strip], :) -fi -INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -AC_SUBST([INSTALL_STRIP_PROGRAM])]) +# serial 4 -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 +# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# --------------------------------------------------------------------------- +# Adds support for distributing Python modules and packages. To +# install modules, copy them to $(pythondir), using the python_PYTHON +# automake variable. To install a package with the same name as the +# automake package, install to $(pkgpythondir), or use the +# pkgpython_PYTHON automake variable. +# +# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as +# locations to install python extension modules (shared libraries). +# Another macro is required to find the appropriate flags to compile +# extension modules. +# +# If your package is configured with a different prefix to python, +# users will have to add the install directory to the PYTHONPATH +# environment variable, or create a .pth file (see the python +# documentation for details). +# +# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will +# cause an error if the version of python installed on the system +# doesn't meet the requirement. MINIMUM-VERSION should consist of +# numbers and dots only. +AC_DEFUN([AM_PATH_PYTHON], + [ + dnl Find a Python interpreter. Python versions prior to 2.0 are not + dnl supported. (2.0 was released on October 16, 2000). + m4_define_default([_AM_PYTHON_INTERPRETER_LIST], + [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl +python2.1 python2.0]) -# _AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. -# This macro is traced by Automake. -AC_DEFUN([_AM_SUBST_NOTMAKE]) + m4_if([$1],[],[ + dnl No version check is needed. + # Find any Python interpreter. + if test -z "$PYTHON"; then + AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) + fi + am_display_PYTHON=python + ], [ + dnl A version check is needed. + if test -n "$PYTHON"; then + # If the user set $PYTHON, use it and don't search something else. + AC_MSG_CHECKING([whether $PYTHON version >= $1]) + AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR(too old)]) + am_display_PYTHON=$PYTHON + else + # Otherwise, try each interpreter until we find one that satisfies + # VERSION. + AC_CACHE_CHECK([for a Python interpreter with version >= $1], + [am_cv_pathless_PYTHON],[ + for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do + test "$am_cv_pathless_PYTHON" = none && break + AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) + done]) + # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. + if test "$am_cv_pathless_PYTHON" = none; then + PYTHON=: + else + AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) + fi + am_display_PYTHON=$am_cv_pathless_PYTHON + fi + ]) -# AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- -# Public sister of _AM_SUBST_NOTMAKE. -AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + if test "$PYTHON" = :; then + dnl Run any user-specified action, or abort. + m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) + else -# Check how to create a tarball. -*- Autoconf -*- + dnl Query Python for its version number. Getting [:3] seems to be + dnl the best way to do this; it's what "site.py" does in the standard + dnl library. -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. + AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], + [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) + AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) -# serial 2 + dnl Use the values of $prefix and $exec_prefix for the corresponding + dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made + dnl distinct variables so they can be overridden if need be. However, + dnl general consensus is that you shouldn't need this ability. -# _AM_PROG_TAR(FORMAT) -# -------------------- -# Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. -# -# Substitute a variable $(am__tar) that is a command -# writing to stdout a FORMAT-tarball containing the directory -# $tardir. -# tardir=directory && $(am__tar) > result.tar -# -# Substitute a variable $(am__untar) that extract such -# a tarball read from stdin. -# $(am__untar) < result.tar -AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. -_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac + AC_SUBST([PYTHON_PREFIX], ['${prefix}']) + AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break + dnl At times (like when building shared libraries) you may want + dnl to know which OS platform Python thinks this is. - # tar/untar a dummy directory, and stop if the command works - rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir + AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], + [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) + AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) -AC_SUBST([am__tar]) -AC_SUBST([am__untar]) -]) # _AM_PROG_TAR -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# -# Copyright © 2004 Scott James Remnant . -# -# 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. + dnl Set up 4 directories: -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl -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 + dnl pythondir -- where to install python scripts. This is the + dnl site-packages directory, not the python standard library + dnl directory like in previous automake betas. This behavior + dnl is more consistent with lispdir.m4 for example. + dnl Query distutils for this directory. distutils does not exist in + dnl Python 1.5, so we fall back to the hardcoded directory if it + dnl doesn't work. + AC_CACHE_CHECK([for $am_display_PYTHON script directory], + [am_cv_python_pythondir], + [if test "x$prefix" = xNONE + then + am_py_prefix=$ac_default_prefix + else + am_py_prefix=$prefix + fi + am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null || + echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"` + case $am_cv_python_pythondir in + $am_py_prefix*) + am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` + am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` + ;; + *) + case $am_py_prefix in + /usr|/System*) ;; + *) + am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages + ;; + esac + ;; + esac + ]) + AC_SUBST([pythondir], [$am_cv_python_pythondir]) -# 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. -# -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure 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_ifval([$2], [$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) + dnl pkgpythondir -- $PACKAGE directory under pythondir. Was + dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is + dnl more consistent with the rest of automake. + AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) -# _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`], - [pkg_failed=yes]) - else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG + dnl pyexecdir -- directory for installing python extension modules + dnl (shared libraries) + dnl Query distutils for this directory. distutils does not exist in + dnl Python 1.5, so we fall back to the hardcoded directory if it + dnl doesn't work. + AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], + [am_cv_python_pyexecdir], + [if test "x$exec_prefix" = xNONE + then + am_py_exec_prefix=$am_py_prefix + else + am_py_exec_prefix=$exec_prefix + fi + am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null || + echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"` + case $am_cv_python_pyexecdir in + $am_py_exec_prefix*) + am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` + am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` + ;; + *) + case $am_py_exec_prefix in + /usr|/System*) ;; + *) + am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages + ;; + esac + ;; + esac + ]) + AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) -# _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 + dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) + AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) -# 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 + dnl Run any user-specified action. + $2 + fi -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.]) +# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# --------------------------------------------------------------------------- +# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. +# Run ACTION-IF-FALSE otherwise. +# This test uses sys.hexversion instead of the string equivalent (first +# word of sys.version), in order to cope with versions such as 2.2c1. +# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). +AC_DEFUN([AM_PYTHON_CHECK_VERSION], + [prog="import sys +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +# map returns an iterator in Python 3.0 and a list in 2.x +minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] +minverhex = 0 +# xrange is not present in Python 3.0 and range returns an iterator +for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] +sys.exit(sys.hexversion < minverhex)" + AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) -if test $pkg_failed = yes; then - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - ifelse([$4], , [AC_MSG_ERROR(dnl -[Package requirements ($2) were not met: +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) -$$1_PKG_ERRORS +# Check to make sure that the build environment is sane. -*- Autoconf -*- -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) -elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl -[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. +# serial 5 -_PKG_TEXT +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac -To get pkg-config, see .])], - [$4]) +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) -fi[]dnl -])# PKG_CHECK_MODULES + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) -# Configure paths for GLIB -# Owen Taylor 1997-2001 +# Copyright (C) 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -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) +# serial 1 - 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 +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# (`yes' being less verbose, `no' or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], +[ --enable-silent-rules less verbose build output (undo: `make V=1') + --disable-silent-rules verbose build output (undo: `make V=0')]) +case $enable_silent_rules in +yes) AM_DEFAULT_VERBOSITY=0;; +no) AM_DEFAULT_VERBOSITY=1;; +*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) - PKG_PROG_PKG_CONFIG([0.16]) +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - no_glib="" +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) - if test "x$PKG_CONFIG" = x ; then - no_glib=yes - PKG_CONFIG=no - fi +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. - min_glib_version=ifelse([$1], ,2.0.0,$1) - AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) +# serial 2 - 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 +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) - if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then - : - else - no_glib=yes - fi - fi +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) - 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` +# Check how to create a tarball. -*- Autoconf -*- - 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 -#include -#include +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. -int -main () -{ - int major, minor, micro; - char *tmp_version; +# serial 2 - fclose (fopen ("conf.glibtest", "w")); +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = g_strdup("$min_glib_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_glib_version"); - exit(1); - } + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break - 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 (%d.%d.%d) was found.\n", - glib_major_version, glib_minor_version, glib_micro_version); - printf("*** You need a version of GLIB newer than %d.%d.%d. 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 -#include -], [ 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="" - ifelse([$3], , :, [$3]) + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi - AC_SUBST(GLIB_CFLAGS) - AC_SUBST(GLIB_LIBS) - AC_SUBST(GLIB_GENMARSHAL) - AC_SUBST(GOBJECT_QUERY) - AC_SUBST(GLIB_MKENUMS) - rm -f conf.glibtest -]) +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR m4_include([m4/as-ac-expand.m4]) m4_include([m4/jhflags.m4]) diff --git a/codegen/Makefile.in b/codegen/Makefile.in index 41778e6..c6672ee 100644 --- a/codegen/Makefile.in +++ b/codegen/Makefile.in @@ -118,6 +118,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/configure b/configure index eeffcf8..839e880 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for pygobject 2.21.5. +# Generated by GNU Autoconf 2.65 for pygobject 2.26.0. # # Report bugs to . # @@ -702,8 +702,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pygobject' PACKAGE_TARNAME='pygobject' -PACKAGE_VERSION='2.21.5' -PACKAGE_STRING='pygobject 2.21.5' +PACKAGE_VERSION='2.26.0' +PACKAGE_STRING='pygobject 2.26.0' PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=pygobject' PACKAGE_URL='' @@ -750,10 +750,13 @@ LTLIBOBJS LIBOBJS INTROSPECTION_COMPILER INTROSPECTION_SCANNER +ENABLE_CAIRO_FALSE +ENABLE_CAIRO_TRUE ENABLE_INTROSPECTION_FALSE ENABLE_INTROSPECTION_TRUE PYCAIRO_LIBS PYCAIRO_CFLAGS +GI_DATADIR GI_LIBS GI_CFLAGS BUILD_GIOUNIX_FALSE @@ -929,6 +932,7 @@ enable_thread enable_docs enable_glibtest with_ffi +enable_cairo enable_introspection ' ac_precious_vars='build_alias @@ -1492,7 +1496,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 2.21.5 to adapt to many kinds of systems. +\`configure' configures pygobject 2.26.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1562,7 +1566,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pygobject 2.21.5:";; + short | recursive ) echo "Configuration of pygobject 2.26.0:";; esac cat <<\_ACEOF @@ -1584,6 +1588,8 @@ Optional Features: --disable-thread Disable pygobject threading support --enable-docs Enable documentation building --disable-glibtest do not try to compile and run a test GLIB program + --enable-cairo Enable Cairo bindings using introspection + information --enable-introspection Use introspection information Optional Packages: @@ -1685,7 +1691,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pygobject configure 2.21.5 +pygobject configure 2.26.0 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -1963,7 +1969,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 2.21.5, which was +It was created by pygobject $as_me 2.26.0, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2321,14 +2327,14 @@ $as_echo "#define PYGOBJECT_MAJOR_VERSION 2" >>confdefs.h PYGOBJECT_MAJOR_VERSION=2 -$as_echo "#define PYGOBJECT_MINOR_VERSION 21" >>confdefs.h +$as_echo "#define PYGOBJECT_MINOR_VERSION 26" >>confdefs.h -PYGOBJECT_MINOR_VERSION=21 +PYGOBJECT_MINOR_VERSION=26 -$as_echo "#define PYGOBJECT_MICRO_VERSION 5" >>confdefs.h +$as_echo "#define PYGOBJECT_MICRO_VERSION 0" >>confdefs.h -PYGOBJECT_MICRO_VERSION=5 +PYGOBJECT_MICRO_VERSION=0 ac_config_headers="$ac_config_headers config.h" @@ -2806,7 +2812,7 @@ fi # Define the identity of the package. PACKAGE='pygobject' - VERSION='2.21.5' + VERSION='2.26.0' cat >>confdefs.h <<_ACEOF @@ -4911,13 +4917,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4914: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4920: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4917: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4923: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4920: output\"" >&5) + (eval echo "\"\$as_me:4926: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6120,7 +6126,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6123 "configure"' > conftest.$ac_ext + echo '#line 6129 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7618,11 +7624,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7621: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7627: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7625: \$? = $ac_status" >&5 + echo "$as_me:7631: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7957,11 +7963,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7960: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7966: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7964: \$? = $ac_status" >&5 + echo "$as_me:7970: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8062,11 +8068,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8065: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8071: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8069: \$? = $ac_status" >&5 + echo "$as_me:8075: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8117,11 +8123,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8120: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8126: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8124: \$? = $ac_status" >&5 + echo "$as_me:8130: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -10487,7 +10493,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10490 "configure" +#line 10496 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10583,7 +10589,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10586 "configure" +#line 10592 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11222,7 +11228,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -pygobject config.lt 2.21.5 +pygobject config.lt 2.26.0 configured by $0, generated by GNU Autoconf 2.65. Copyright (C) 2008 Free Software Foundation, Inc. @@ -13696,6 +13702,7 @@ fi +# check that we have the minimum version of python necisary to build @@ -13881,6 +13888,51 @@ $as_echo "$am_cv_python_pyexecdir" >&6; } +# check if we are building for python 3 +prog="import sys +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +# map returns an iterator in Python 3.0 and a list in 2.x +minver = list(map(int, '3.0'.split('.'))) + [0, 0, 0] +minverhex = 0 +# xrange is not present in Python 3.0 and range returns an iterator +for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i] +sys.exit(sys.hexversion < minverhex)" + if { echo "$as_me:$LINENO: $PYTHON -c "$prog"" >&5 + ($PYTHON -c "$prog") >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then : + build_py3k=true +else + build_py3k=false +fi + +# if building for python 3 make sure we have the minimum version supported +if test $build_py3k = true ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $PYTHON >= 3.1" >&5 +$as_echo_n "checking for $PYTHON >= 3.1... " >&6; } + prog="import sys +# split strings by '.' and convert to numeric. Append some zeros +# because we need at least 4 digits for the hex conversion. +# map returns an iterator in Python 3.0 and a list in 2.x +minver = list(map(int, '3.1'.split('.'))) + [0, 0, 0] +minverhex = 0 +# xrange is not present in Python 3.0 and range returns an iterator +for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i] +sys.exit(sys.hexversion < minverhex)" + if { echo "$as_me:$LINENO: $PYTHON -c "$prog"" >&5 + ($PYTHON -c "$prog") >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + as_fn_error "too old" "$LINENO" 5 +fi +fi + @@ -14811,7 +14863,10 @@ $as_echo "yes" >&6; } fi - if $have_gio; then + +# Do not build GIO if the python version >= 3.0 +# We use GI to access GIO in python 3 + if test $have_gio = true -a $build_py3k = false; then BUILD_GIO_TRUE= BUILD_GIO_FALSE='#' else @@ -14819,6 +14874,7 @@ else BUILD_GIO_FALSE= fi + if test -n "$export_dynamic"; then GIO_LIBS=`echo $GIO_LIBS | sed -e "s/$export_dynamic//"` fi @@ -14892,7 +14948,7 @@ $as_echo "yes" >&6; } fi - if $have_giounix; then + if test $have_giounix = true -a $build_py3k = false; then BUILD_GIOUNIX_TRUE= BUILD_GIOUNIX_FALSE='#' else @@ -14904,6 +14960,14 @@ if test -n "$export_dynamic"; then GIOUNIX_LIBS=`echo $GIOUNIX_LIBS | sed -e "s/$export_dynamic//"` fi +# Check whether --enable-cairo was given. +if test "${enable_cairo+set}" = set; then : + enableval=$enable_cairo; enable_cairo=$enableval +else + enable_cairo=yes +fi + + # Check whether --enable-introspection was given. if test "${enable_introspection+set}" = set; then : enableval=$enable_introspection; enable_introspection=$enableval @@ -14925,16 +14989,16 @@ if test -n "$GI_CFLAGS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 \""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GI_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 " 2>/dev/null` else pkg_failed=yes @@ -14947,16 +15011,16 @@ if test -n "$GI_LIBS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 \""; } >&5 ($PKG_CONFIG --exists --print-errors "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GI_LIBS=`$PKG_CONFIG --libs "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 " 2>/dev/null` else pkg_failed=yes @@ -14976,18 +15040,18 @@ else fi if test $_pkg_short_errors_supported = yes; then GI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 " 2>&1` else GI_PKG_ERRORS=`$PKG_CONFIG --print-errors "glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GI_PKG_ERRORS" >&5 as_fn_error "Package requirements (glib-2.0 >= 2.22.4 - gobject-introspection-1.0 >= 0.9.1 + gobject-introspection-1.0 >= 0.9.5 ) were not met: $GI_PKG_ERRORS @@ -15020,6 +15084,11 @@ $as_echo "yes" >&6; } : fi + GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0) + + + if test "$enable_cairo" != no; then + pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYCAIRO" >&5 $as_echo_n "checking for PYCAIRO... " >&6; } @@ -15029,14 +15098,14 @@ if test -n "$PYCAIRO_CFLAGS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pycairo >= 1.0.2 - \""; } >&5 + \""; } >&5 ($PKG_CONFIG --exists --print-errors "pycairo >= 1.0.2 - ") 2>&5 + ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PYCAIRO_CFLAGS=`$PKG_CONFIG --cflags "pycairo >= 1.0.2 - " 2>/dev/null` + " 2>/dev/null` else pkg_failed=yes fi @@ -15048,14 +15117,14 @@ if test -n "$PYCAIRO_LIBS"; then elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"pycairo >= 1.0.2 - \""; } >&5 + \""; } >&5 ($PKG_CONFIG --exists --print-errors "pycairo >= 1.0.2 - ") 2>&5 + ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PYCAIRO_LIBS=`$PKG_CONFIG --libs "pycairo >= 1.0.2 - " 2>/dev/null` + " 2>/dev/null` else pkg_failed=yes fi @@ -15074,16 +15143,16 @@ else fi if test $_pkg_short_errors_supported = yes; then PYCAIRO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "pycairo >= 1.0.2 - " 2>&1` + " 2>&1` else PYCAIRO_PKG_ERRORS=`$PKG_CONFIG --print-errors "pycairo >= 1.0.2 - " 2>&1` + " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PYCAIRO_PKG_ERRORS" >&5 as_fn_error "Package requirements (pycairo >= 1.0.2 - ) were not met: + ) were not met: $PYCAIRO_PKG_ERRORS @@ -15114,6 +15183,7 @@ else $as_echo "yes" >&6; } : fi + fi fi if test "$enable_introspection" = "yes"; then ENABLE_INTROSPECTION_TRUE= @@ -15123,6 +15193,14 @@ else ENABLE_INTROSPECTION_FALSE= fi + if test "$enable_cairo" = "yes"; then + ENABLE_CAIRO_TRUE= + ENABLE_CAIRO_FALSE='#' +else + ENABLE_CAIRO_TRUE='#' + ENABLE_CAIRO_FALSE= +fi + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` @@ -15395,6 +15473,10 @@ if test -z "${ENABLE_INTROSPECTION_TRUE}" && test -z "${ENABLE_INTROSPECTION_FAL as_fn_error "conditional \"ENABLE_INTROSPECTION\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_CAIRO_TRUE}" && test -z "${ENABLE_CAIRO_FALSE}"; then + as_fn_error "conditional \"ENABLE_CAIRO\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : ${CONFIG_STATUS=./config.status} ac_write_fail=0 @@ -15803,7 +15885,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 2.21.5, which was +This file was extended by pygobject $as_me 2.26.0, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15869,7 +15951,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 2.21.5 +pygobject config.status 2.26.0 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index c2328af..290c4de 100644 --- a/configure.ac +++ b/configure.ac @@ -1,14 +1,22 @@ -*- mode: m4 -*- AC_PREREQ(2.52) +# The version of python used is determined by the executable pointed to by +# the PYTHON environment variable. For instance if your system installs +# Python 3 as python3 to configure to compile pygobject under Python 3 +# you would do this: +# $> PYTHON=python3 ./configure +m4_define(python_min_ver, 2.5.2) +m4_define(python3_min_ver, 3.1) + dnl the pygobject version number m4_define(pygobject_major_version, 2) -m4_define(pygobject_minor_version, 21) -m4_define(pygobject_micro_version, 5) +m4_define(pygobject_minor_version, 26) +m4_define(pygobject_micro_version, 0) m4_define(pygobject_version, pygobject_major_version.pygobject_minor_version.pygobject_micro_version) dnl versions of packages we require ... -m4_define(introspection_required_version, 0.9.1) +m4_define(introspection_required_version, 0.9.5) m4_define(pycairo_required_version, 1.0.2) m4_define(glib_required_version, 2.22.4) m4_define(gio_required_version, 2.22.4) @@ -77,7 +85,21 @@ AC_PROG_CC AM_PROG_CC_STDC AM_PROG_CC_C_O -JD_PATH_PYTHON(2.5.2) +# check that we have the minimum version of python necisary to build +JD_PATH_PYTHON(python_min_ver) + +# check if we are building for python 3 +JD_PYTHON_CHECK_VERSION([$PYTHON], [3.0], + build_py3k=true, + build_py3k=false) + +# if building for python 3 make sure we have the minimum version supported +if test $build_py3k = true ; then + AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver) + JD_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver, + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR(too old)]) +fi JD_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) @@ -189,7 +211,11 @@ PKG_CHECK_MODULES(GIO, gio-2.0 >= gio_required_version, have_gio=true, have_gio=false) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) -AM_CONDITIONAL(BUILD_GIO, $have_gio) + +# Do not build GIO if the python version >= 3.0 +# We use GI to access GIO in python 3 +AM_CONDITIONAL(BUILD_GIO, test $have_gio = true -a $build_py3k = false) + if test -n "$export_dynamic"; then GIO_LIBS=`echo $GIO_LIBS | sed -e "s/$export_dynamic//"` fi @@ -199,11 +225,16 @@ PKG_CHECK_MODULES(GIOUNIX, gio-unix-2.0 >= giounix_required_version, have_giounix=true, have_giounix=false) AC_SUBST(GIOUNIX_CFLAGS) AC_SUBST(GIOUNIX_LIBS) -AM_CONDITIONAL(BUILD_GIOUNIX, $have_giounix) +AM_CONDITIONAL(BUILD_GIOUNIX, test $have_giounix = true -a $build_py3k = false) if test -n "$export_dynamic"; then GIOUNIX_LIBS=`echo $GIOUNIX_LIBS | sed -e "s/$export_dynamic//"` fi +AC_ARG_ENABLE(cairo, + AC_HELP_STRING([--enable-cairo], [Enable Cairo bindings using introspection information]), + enable_cairo=$enableval, + enable_cairo=yes) + AC_ARG_ENABLE(introspection, AC_HELP_STRING([--enable-introspection], [Use introspection information]), enable_introspection=$enableval, @@ -214,11 +245,18 @@ if test "$enable_introspection" != no; then glib-2.0 >= glib_required_version gobject-introspection-1.0 >= introspection_required_version ) - PKG_CHECK_MODULES(PYCAIRO, - pycairo >= pycairo_required_version - ) + + GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0) + AC_SUBST(GI_DATADIR) + + if test "$enable_cairo" != no; then + PKG_CHECK_MODULES(PYCAIRO, + pycairo >= pycairo_required_version + ) + fi fi AM_CONDITIONAL(ENABLE_INTROSPECTION, test "$enable_introspection" = "yes") +AM_CONDITIONAL(ENABLE_CAIRO, test "$enable_cairo" = "yes") INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` diff --git a/docs/Makefile.in b/docs/Makefile.in index 27d1c61..b9a3bcb 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -115,6 +115,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/docs/html/class-gioappinfo.html b/docs/html/class-gioappinfo.html index 7942ff9..7ae7519 100644 --- a/docs/html/class-gioappinfo.html +++ b/docs/html/class-gioappinfo.html @@ -1,13 +1,13 @@ -gio.AppInfo

gio.AppInfo

gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).

Synopsis

class gio.AppInfo(gobject.GInterface):
+gio.AppInfo

gio.AppInfo

gio.AppInfo — Information about an installed application and methods to launch it (with file arguments).

Synopsis

class gio.AppInfo(gobject.GInterface):
     gio.AppInfo(commandline, application_name=None, flags=gio.APP_INFO_CREATE_NONE)
def add_supports_type(content_type)
def can_delete()
def can_remove_supports_type()
def delete()
def dup()
def equal(appinfo2)
def get_commandline()
def get_description()
def get_executable()
def get_icon()
def get_id()
def get_name()
def launch(files, launch_context)
def launch_uris(uris, launch_context)
def remove_supports_type(content_type)
def set_as_default_for_extension(extension)
def set_as_default_for_type(content_type)
def should_show()
def supports_files()
def supports_uris()
 Functions
  
-    def gio.app_info_get_all()
def gio.app_info_get_all_for_type(content_type)
def gio.app_info_get_default_for_type(content_type, must_support_uris)
def gio.app_info_get_default_for_uri_scheme(uri_scheme)
def gio.app_info_reset_type_association(content_type)

Known Implementation

+

Known Implementation

gio.AppInfo is implemented by gio.DesktopAppInfo -

Description

+

Description

gio.AppInfo and gio.AppLaunchContext are used for describing and launching applications installed on the system. @@ -43,7 +43,7 @@

Creates a new gio.AppInfo from the given information. -

Methods

gio.AppInfo.add_supports_type

    def add_supports_type(content_type)

content_type :

A string.

+

Methods

gio.AppInfo.add_supports_type

    def add_supports_type(content_type)

content_type :

A string.

The add_supports_type() method adds a content type to the application information to indicate the application is capable of opening files with the given content type. @@ -166,7 +166,7 @@

The supports_uris() method checks if the application accepts uris as arguments. -

Functions

gio.app_info_get_all

    def app_info_get_all()

Returns :

A list of gio.AppInfos. +

Functions

gio.app_info_get_all

    def app_info_get_all()

Returns :

A list of gio.AppInfos.

The app_info_get_all() function gets a list of all of the applications currently registered on this system. diff --git a/docs/html/class-gioapplaunchcontext.html b/docs/html/class-gioapplaunchcontext.html index 32c735f..ba533cf 100644 --- a/docs/html/class-gioapplaunchcontext.html +++ b/docs/html/class-gioapplaunchcontext.html @@ -1,7 +1,7 @@ -gio.AppLaunchContext

gio.AppLaunchContext

gio.AppLaunchContext — Application launch context.

Synopsis

class gio.AppLaunchContext(gobject.GObject):
-    gio.AppLaunchContext()
def get_display(info, files)
def get_startup_notify_id(info, files)
def launch_failed(startup_notify_id)

Ancestry

+-- gobject.GObject
+gio.AppLaunchContext

gio.AppLaunchContext

gio.AppLaunchContext — Application launch context.

Synopsis

class gio.AppLaunchContext(gobject.GObject):
+    gio.AppLaunchContext()
def get_display(info, files)
def get_startup_notify_id(info, files)
def launch_failed(startup_notify_id)

Description

+

Description

The gio.AppLaunchContext is used for integrating the launch with the launching application. This is used to handle for instance startup notification and launching the new application on the same screen as the launching window. @@ -11,7 +11,7 @@ Creates a new application launch context. This is not normally used, instead you instantiate a subclass of this, such as gtk.gdk.AppLaunchContext. -

Methods

gio.AppLaunchContext.get_display

    def get_display(info, files)

info :

a +

Methods

gio.AppLaunchContext.get_display

    def get_display(info, files)

info :

a gio.AppInfo

files :

a list of gio.File diff --git a/docs/html/class-gioasyncresult.html b/docs/html/class-gioasyncresult.html index 39f491f..e897bd6 100644 --- a/docs/html/class-gioasyncresult.html +++ b/docs/html/class-gioasyncresult.html @@ -1,13 +1,13 @@ -gio.AsyncResult

gio.AsyncResult

gio.AsyncResult — Asynchronous Function Results.

Synopsis

class gio.AsyncResult(gobject.GInterface):
-    def get_source_object()

Ancestry

+-- gobject.GInterface
+gio.AsyncResult

gio.AsyncResult

gio.AsyncResult — Asynchronous Function Results.

Synopsis

class gio.AsyncResult(gobject.GInterface):
+    def get_source_object()

Prerequisites

+

Prerequisites

gio.AsyncResult is required by gobject.GObject. -

Known Implementation

+

Known Implementation

gio.AsyncResult is implemented by gio.SimpleAsyncResult. -

Description

+

Description

gio.AsyncResult provides a base class for implementing asynchronous function results.

@@ -37,7 +37,7 @@ separate thread, if GThread has been initialized, but otherwise they are sent to the Main Event Loop and processed in an idle function. So, if you truly need asynchronous operations, make sure to initialize GThread. -

Methods

gio.AsyncResult.get_source_object

    def get_source_object()

Returns :

the source object for the res. +

Methods

gio.AsyncResult.get_source_object

    def get_source_object()

Returns :

the source object for the res.

The get_source_object() method gets the source object from a gio.AsyncResult diff --git a/docs/html/class-giobufferedinputstream.html b/docs/html/class-giobufferedinputstream.html index 2f2f5d6..f825c5e 100644 --- a/docs/html/class-giobufferedinputstream.html +++ b/docs/html/class-giobufferedinputstream.html @@ -1,12 +1,12 @@ -gio.BufferedInputStream

gio.BufferedInputStream

gio.BufferedInputStream — Buffered Input Stream

Synopsis

class gio.BufferedInputStream(gio.FilterInputStream):
+gio.BufferedInputStream

gio.BufferedInputStream

gio.BufferedInputStream — Buffered Input Stream

Synopsis

class gio.BufferedInputStream(gio.FilterInputStream):
     gio.BufferedInputStream(base_stream)
def fill(count, cancellable=None)
def fill_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def fill_finish(result)
def get_available()
def get_buffer_size()
def read_byte(cancellable=None)
def set_buffer_size(size)
 Functions
  
-    def gio.buffered_input_stream_new_sized(size)

gio.BufferedInputStream Properties

"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

+

gio.BufferedInputStream Properties

"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

gio.BufferedInputStream implements gio.FilterInputStream and provides for buffered reads. @@ -33,7 +33,7 @@

Creates a new gio.InputStream from the given base_stream, with a buffer set to the default size (4 kilobytes). -

Methods

gio.BufferedInputStream.fill

    def fill(count, cancellable=None)

count :

the number of bytes that will be read from the stream. +

Methods

gio.BufferedInputStream.fill

    def fill(count, cancellable=None)

count :

the number of bytes that will be read from the stream.

cancellable :

optional gio.Cancellable object, None to ignore. @@ -123,7 +123,7 @@ The set_buffer_size() method sets the size of the internal buffer of stream to size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents. -

Functions

gio.buffered_input_stream_new_sized

    def buffered_input_stream_new_sized(size)

size :

the requested buffer size. +

Functions

gio.buffered_input_stream_new_sized

    def buffered_input_stream_new_sized(size)

size :

the requested buffer size.

Returns :

A new gio.InputStream.

diff --git a/docs/html/class-giobufferedoutputstream.html b/docs/html/class-giobufferedoutputstream.html index 400e153..860d82a 100644 --- a/docs/html/class-giobufferedoutputstream.html +++ b/docs/html/class-giobufferedoutputstream.html @@ -1,12 +1,12 @@ -gio.BufferedOutputStream

gio.BufferedOutputStream

gio.BufferedOutputStream — Buffered Output Stream

Synopsis

class gio.BufferedOutputStream(gio.FilterOutputStream):
+gio.BufferedOutputStream

gio.BufferedOutputStream

gio.BufferedOutputStream — Buffered Output Stream

Synopsis

class gio.BufferedOutputStream(gio.FilterOutputStream):
     gio.BufferedOutputStream(base_stream)
def get_auto_grow()
def get_buffer_size()
def set_auto_grow(auto_grow)
def set_buffer_size(size)
 Functions
  
-    def gio.buffered_output_stream_new_sized(size)

gio.BufferedOutputStream Properties

"auto-grow"Read - WriteWhether the buffer should automatically grow. Default value: False.
"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

+

gio.BufferedOutputStream Properties

"auto-grow"Read - WriteWhether the buffer should automatically grow. Default value: False.
"buffer-size"Read - Write - ConstructThe size of the backend buffer. Allowed values: >= 1. Default value: 4096.

Description

gio.BufferedOutputStream implements gio.FilterOutputStream and provides for buffered writes. @@ -32,7 +32,7 @@ for the given base_stream.

Creates a new buffered output stream for a base stream. -

Methods

gio.BufferedOutputStream.get_auto_grow

    def get_auto_grow()

Returns :

True if the stream's +

Methods

gio.BufferedOutputStream.get_auto_grow

    def get_auto_grow()

Returns :

True if the stream's buffer automatically grows, False otherwise.

The get_auto_grow() method checks if the @@ -51,7 +51,7 @@

The set_buffer_size() method sets the size of the internal buffer to size. -

Functions

gio.buffered_output_stream_new_sized

    def buffered_output_stream_new_sized(size)

size :

the requested buffer size. +

Functions

gio.buffered_output_stream_new_sized

    def buffered_output_stream_new_sized(size)

size :

the requested buffer size.

Returns :

A new gio.OutputStream with an internal buffer set to size.. diff --git a/docs/html/class-giocancellable.html b/docs/html/class-giocancellable.html index 67de087..3947a8c 100644 --- a/docs/html/class-giocancellable.html +++ b/docs/html/class-giocancellable.html @@ -1,10 +1,10 @@ -gio.Cancellable

gio.Cancellable

gio.Cancellable — Thread-safe Operation Cancellation Stack.

Synopsis

class gio.Cancellable(gobject.GObject):
+gio.Cancellable

gio.Cancellable

gio.Cancellable — Thread-safe Operation Cancellation Stack.

Synopsis

class gio.Cancellable(gobject.GObject):
     gio.Cancellable()
def cancel()
def get_fd()
def is_cancelled()
def pop_current()
def push_current()
def reset()
def set_error_if_cancelled()
 Functions
  
-    def gio.cancellable_get_current()

Description

+

Description

The gio.Cancellable is a thread-safe operation cancellation stack used throughout GIO to allow for cancellation of synchronous and asynchronous operations. @@ -19,7 +19,7 @@

One gio.Cancellable can be used in multiple consecutive operations, but not in multiple concurrent operations. -

Methods

gio.Cancellable.cancel

    def cancel()

+

Methods

gio.Cancellable.cancel

    def cancel()

The cancel() method will set cancellable to cancelled, and will emit the "cancelled" signal. (However, see the warning about race conditions in the documentation for that signal if you are planning to connect to it.) @@ -55,7 +55,7 @@ False if it was not.

The set_error_if_cancelled() method, if the cancellable is cancelled, sets the error to notify that the operation was cancelled. -

Functions

gio.cancellable_get_current

    def cancellable_get_current()

Returns :

A gio.Cancellable +

Functions

gio.cancellable_get_current

    def cancellable_get_current()

Returns :

A gio.Cancellable from the top of the stack, or None if the stack is empty.

The cancellable_get_current() function gets the top cancellable from the stack.

diff --git a/docs/html/class-giodatainputstream.html b/docs/html/class-giodatainputstream.html index c88c2cb..7e32d26 100644 --- a/docs/html/class-giodatainputstream.html +++ b/docs/html/class-giodatainputstream.html @@ -1,10 +1,10 @@ -gio.DataInputStream

gio.DataInputStream

gio.DataInputStream — Data Input Stream

Synopsis

class gio.DataInputStream(gio.BufferedInputStream):
-    gio.DataInputStream(base_stream)
def get_byte_order()
def get_newline_type()
def read_byte(cancellable=None)
def read_int16(cancellable=None)
def read_int32(cancellable=None)
def read_int64(cancellable=None)
def read_line(cancellable=None)
def read_line_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_line_finish(result)
def read_uint16(cancellable=None)
def read_uint32(cancellable=None)
def read_uint64(cancellable=None)
def read_until(stop_chars, cancellable=None)
def read_until_async(stop_chars, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_until_finish(result)
def set_byte_order(order)
def set_newline_type(type)

Ancestry

+-- gobject.GObject
+gio.DataInputStream

gio.DataInputStream

gio.DataInputStream — Data Input Stream

Synopsis

class gio.DataInputStream(gio.BufferedInputStream):
+    gio.DataInputStream(base_stream)
def get_byte_order()
def get_newline_type()
def read_byte(cancellable=None)
def read_int16(cancellable=None)
def read_int32(cancellable=None)
def read_int64(cancellable=None)
def read_line(cancellable=None)
def read_line_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_line_finish(result)
def read_uint16(cancellable=None)
def read_uint32(cancellable=None)
def read_uint64(cancellable=None)
def read_until(stop_chars, cancellable=None)
def read_until_async(stop_chars, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_until_finish(result)
def set_byte_order(order)
def set_newline_type(type)

gio.DataInputStream Properties

"byte-order"Read - WriteThe byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.
"newline-type"Read - WriteThe accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.

Description

+

gio.DataInputStream Properties

"byte-order"Read - WriteThe byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.
"newline-type"Read - WriteThe accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.

Description

gio.DataInputStream implements gio.InputStream and includes functions for reading structured data directly from a binary input stream. @@ -15,7 +15,7 @@

Creates a new gio.DataInputStream from the given base_stream. -

Methods

gio.DataInputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current +

Methods

gio.DataInputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current Gio Data Stream Byte Order Constants.

The get_byte_order() method gets the byte diff --git a/docs/html/class-giodataoutputstream.html b/docs/html/class-giodataoutputstream.html index f6f9980..b544099 100644 --- a/docs/html/class-giodataoutputstream.html +++ b/docs/html/class-giodataoutputstream.html @@ -1,12 +1,12 @@ -gio.DataOutputStream

gio.DataOutputStream

gio.DataOutputStream — Data Output Stream

Synopsis

class gio.DataOutputStream(gio.BufferedOutputStream):
-    gio.DataOutputStream(base_stream)
def get_byte_order()
def put_byte(cancellable=None)
def put_int16(cancellable=None)
def put_int32(cancellable=None)
def put_int64(cancellable=None)
def put_string(cancellable=None)
def put_uint16(cancellable=None)
def put_uint32(cancellable=None)
def put_uint64(cancellable=None)
def set_byte_order(order)

Ancestry

+-- gobject.GObject
+gio.DataOutputStream

gio.DataOutputStream

gio.DataOutputStream — Data Output Stream

Synopsis

class gio.DataOutputStream(gio.BufferedOutputStream):
+    gio.DataOutputStream(base_stream)
def get_byte_order()
def put_byte(cancellable=None)
def put_int16(cancellable=None)
def put_int32(cancellable=None)
def put_int64(cancellable=None)
def put_string(cancellable=None)
def put_uint16(cancellable=None)
def put_uint32(cancellable=None)
def put_uint64(cancellable=None)
def set_byte_order(order)

gio.DataOutputStream Properties

"byte-order"Read - WriteDetermines the byte ordering that is used when writing multi-byte entities (such as integers) to the stream. - Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.

Description

+ Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.

Description

gio.DataOutputStream implements gio.InputStream and includes functions for writing data directly to an output stream. @@ -17,7 +17,7 @@

Creates a new gio.DataOutputStream from the given base_stream. -

Methods

gio.DataOutputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current +

Methods

gio.DataOutputStream.get_byte_order

    def get_byte_order()

Returns :

the stream's current Gio Data Stream Byte Order Constants.

The get_byte_order() method gets the byte diff --git a/docs/html/class-giodrive.html b/docs/html/class-giodrive.html index dba9dcf..d618c05 100644 --- a/docs/html/class-giodrive.html +++ b/docs/html/class-giodrive.html @@ -1,10 +1,10 @@ -gio.Drive

gio.Drive

gio.Drive — Virtual File System drive management.

Synopsis

class gio.Drive(gobject.GInterface):
-    def can_eject()
def can_poll_for_media()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_icon()
def get_identifier()
def get_name()
def get_volumes()
def has_media()
def has_volumes()
def is_media_check_automatic()
def is_media_removable()
def poll_for_media(callback, cancellable=None, user_data=None)
def poll_for_media_finish(result)

Ancestry

+-- gobject.GInterface
+gio.Drive

gio.Drive

gio.Drive — Virtual File System drive management.

Synopsis

class gio.Drive(gobject.GInterface):
+    def can_eject()
def can_poll_for_media()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_icon()
def get_identifier()
def get_name()
def get_volumes()
def has_media()
def has_volumes()
def is_media_check_automatic()
def is_media_removable()
def poll_for_media(callback, cancellable=None, user_data=None)
def poll_for_media_finish(result)

Ancestry

+-- gobject.GInterface
   +-- gio.Drive
-

Prerequisites

+

Prerequisites

gio.Drive requires gobject.GObject -

Description

+

Description

gio.Drive - this represent a piece of hardware connected to the machine. Its generally only created for removable hardware or hardware with removable media. @@ -24,7 +24,7 @@ For porting from GnomeVFS note that there is no equivalent of gio.Drive in that API. -

Methods

gio.Drive.can_eject

    def can_eject()

Returns :

True if the drive can be ejected, +

Methods

gio.Drive.can_eject

    def can_eject()

Returns :

True if the drive can be ejected, False otherwise.

The can_eject() method checks if a drive can be ejected. diff --git a/docs/html/class-gioemblem.html b/docs/html/class-gioemblem.html index 0834b0f..68fa143 100644 --- a/docs/html/class-gioemblem.html +++ b/docs/html/class-gioemblem.html @@ -1,14 +1,14 @@ -gio.Emblem

gio.Emblem

gio.Emblem — An object for emblems.

Synopsis

class gio.Emblem(gobject.GObject, gio.Icon):
+gio.Emblem

gio.Emblem

gio.Emblem — An object for emblems.

Synopsis

class gio.Emblem(gobject.GObject, gio.Icon):
     gio.Emblem(icon, origin=gio.EMBLEM_ORIGIN_UNKNOWN)
def get_icon()
def get_origin()
 Functions
  
-    def gio.emblem_new_with_origin(icon, origin)

Ancestry

+-- gobject.GObject
+    def gio.emblem_new_with_origin(icon, origin)

Ancestry

+-- gobject.GObject
   +-- gio.Emblem
-

Implemented Interfaces

+

Implemented Interfaces

gio.Emblem implements gio.Icon -

gio.Emblem Properties

"icon"Read - Write - Construct OnlyThe actual icon of the emblem.
"origin"Read - Write - Construct OnlyTells which origin the emblem is derived from.

Description

+

gio.Emblem Properties

"icon"Read - Write - Construct OnlyThe actual icon of the emblem.
"origin"Read - Write - Construct OnlyTells which origin the emblem is derived from.

Description

The gio.Emblem class is an implementation of gio.Icon that supports having an emblem, which is an icon with additional properties. @@ -27,14 +27,14 @@ Parameter origin is available since PyGObject 2.20.

Creates a new gio.Emblem for icon. -

Methods

gio.Emblem.get_icon

    def get_icon()

Returns :

a +

Methods

gio.Emblem.get_icon

    def get_icon()

Returns :

a gio.Icon.

The get_icon() method gives back the icon from emblem.

gio.Emblem.get_origin

    def get_origin()

Returns :

the origin of the emblem.

The get_origin() method gets the origin of the emblem. -

Functions

gio.emblem_new_with_origin

    def emblem_new_with_origin(icon, origin)

origin :

a Gio Emblem Origin Constants +

Functions

gio.emblem_new_with_origin

    def emblem_new_with_origin(icon, origin)

origin :

a Gio Emblem Origin Constants defining the emblem's origin.

Returns :

A gio.Emblem.

Note

diff --git a/docs/html/class-gioemblemedicon.html b/docs/html/class-gioemblemedicon.html index 5c474f5..8defb35 100644 --- a/docs/html/class-gioemblemedicon.html +++ b/docs/html/class-gioemblemedicon.html @@ -1,11 +1,11 @@ -gio.EmblemedIcon

gio.EmblemedIcon

gio.EmblemedIcon — Icon with emblems.

Synopsis

class gio.EmblemedIcon(gobject.GObject, gio.Icon):
-    gio.EmblemedIcon(icon, emblem)
def add_emblem(emblem)
def get_icon()

Ancestry

+-- gobject.GObject
+gio.EmblemedIcon

gio.EmblemedIcon

gio.EmblemedIcon — Icon with emblems.

Synopsis

class gio.EmblemedIcon(gobject.GObject, gio.Icon):
+    gio.EmblemedIcon(icon, emblem)
def add_emblem(emblem)
def get_icon()

Implemented Interfaces

+

Implemented Interfaces

gio.EmblemedIcon implements gio.Icon -

Description

+

Description

The gio.EmblemedIcon class is an implementation of gio.Icon that supports adding an emblem to an icon. Adding multiple emblems to an icon is ensured via @@ -25,7 +25,7 @@

Creates a new gio.Icon for icon with the emblem emblem. -

Methods

gio.EmblemedIcon.add_emblem

    def add_emblem(emblem)

emblem :

a +

Methods

gio.EmblemedIcon.add_emblem

    def add_emblem(emblem)

emblem :

a gio.Emblem

The add_emblem() method adds emblem to the diff --git a/docs/html/class-giofile.html b/docs/html/class-giofile.html index f18df5e..bf3dc0e 100644 --- a/docs/html/class-giofile.html +++ b/docs/html/class-giofile.html @@ -1,12 +1,12 @@ -gio.File

gio.File

gio.File — File and Directory Handling.

Synopsis

class gio.File(gobject.GInterface):
+gio.File

gio.File

gio.File — File and Directory Handling.

Synopsis

class gio.File(gobject.GInterface):
     gio.File(commandline, path=None, uri=None)
def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)
def append_to_async(callback, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def append_to_finish(result)
def copy(destination, progress_callback, flags=gio.FILE_COPY_NONE, cancellable=None, user_data=None)
def copy_async(destination, callback, progress_callback=None, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None, progress_callback_data=None)
def copy_attributes(destination, flags=gio.FILE_COPY_NONE, cancellable=None)
def copy_finish(result)
def create(flags=gio.FILE_CREATE_NONE, cancellable=None)
def create_async(callback, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def create_finish(result)
def delete(cancellable=None)
def dup()
def eject_mountable(callback, flags=gio.FILE_CREATE_NONE, cancellable=None, user_data=None)
def eject_mountable_finish(result)
def enumerate_children(attributes, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def enumerate_children_async(attributes, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def enumerate_children_finish(result)
def equal(file2)
def find_enclosing_mount(cancellable)
def find_enclosing_mount_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def find_enclosing_mount_finish(result)
def get_basename()
def get_child(name)
def get_child_for_display_name(display_name)
def get_parent()
def get_parse_name()
def get_path()
def get_relative_path(descendant)
def get_uri()
def get_uri_scheme()
def has_prefix(prefix)
def has_uri_scheme(uri_scheme)
def is_native()
def load_contents(cancellable)
def load_contents_async(callback, cancellable=None, user_data=None)
def load_contents_finish(result)
def make_directory(cancellable=None)
def make_directory_with_parents(cancellable=None)
def make_symbolic_link(symlink_value, cancellable)
def monitor(flags=gio.FILE_MONITOR_NONE, cancellable=None)
def monitor_directory(flags, cancellable=None)
def monitor_file(flags, cancellable=None)
def mount_enclosing_volume(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_enclosing_volume_finish(result)
def mount_mountable(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_mountable_finish(result)
def move(destination, progress_callback, flags=gio.FILE_COPY_NONE, cancellable=None, user_data=None)
def query_default_handler(cancellable)
def query_exists(cancellable)
def query_file_type(flags, cancellable)
def query_filesystem_info(attributes, cancellable)
def query_filesystem_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_filesystem_info_finish(result)
def query_info(attributes, flags, cancellable)
def query_info_async(attributes, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)
def query_settable_attributes(cancellable=None)
def query_writable_namespace(cancellable=None)
def read(cancellable=None)
def read_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result=None)
def replace(etag, make_backup, flags=gio.FILE_CREATE_NONE, cancellable=None)
def replace_async(callback, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def replace_contents(contents, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, cancellable=None)
def replace_contents_async(contents, callback, etag=None, make_backup=True, flags=gio.FILE_CREATE_NONE, cancellable=None, user_data=None)
def replace_contents_finish(result=None)
def replace_finish(result=None)
def resolve_relative_path(relative_path)
def set_attribute(attribute, type, value_p, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_byte_string(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_int32(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_int64(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_string(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_uint32(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attribute_uint64(attribute, value, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_attributes_async(info, callback, flags=gio.FILE_QUERY_INFO_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def set_attributes_finish(result)
def set_attributes_from_info(info, flags=gio.FILE_QUERY_INFO_NONE, cancellable=None)
def set_dispay_name(display_name, cancellable=None)
def set_display_name_async(display_name, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def set_display_name_finish(result)
def trash(cancellable=None)
def unmount_mountable(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_mountable_finish(cancellable=None)
 Functions
-    def gio.file_parse_name(parse_name)

Ancestry

+-- gobject.GInterface
+    def gio.file_parse_name(parse_name)

Ancestry

+-- gobject.GInterface
   +-- gio.File
-

Prerequisites

+

Prerequisites

gio.File is implemented by gobject.GObject -

Description

+

Description

gio.File is a high level abstraction for manipulating files on a virtual file system. gio.Files are lightweight, @@ -91,7 +91,7 @@

Creates a new gio.File either from a commandline, a path or an uri. -

Methods

gio.File.append_to

    def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)

flags :

a set of +

Methods

gio.File.append_to

    def append_to(flags=gio.FILE_CREATE_NONE, cancellable=None)

flags :

a set of Gio File Create Flags Constants

cancellable :

optional gio.Cancellable @@ -1425,7 +1425,7 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] The unmount_mountable_finish() method finishes an asynchronous copy operation started with gio.File.unmount_mountable(). -

Functions

gio.file_parse_name

    def file_parse_name(parse_name)

parse_name :

a file name or path to be parsed. +

Functions

gio.file_parse_name

    def file_parse_name(parse_name)

parse_name :

a file name or path to be parsed.

Returns :

a new gio.File.

The parse_name() function constructs a diff --git a/docs/html/class-giofileattributeinfo.html b/docs/html/class-giofileattributeinfo.html index d46cd57..1061750 100644 --- a/docs/html/class-giofileattributeinfo.html +++ b/docs/html/class-giofileattributeinfo.html @@ -1,7 +1,7 @@ -gio.FileAttributeInfo

gio.FileAttributeInfo

gio.FileAttributeInfo — Information about a specific attribute.

Synopsis

class gio.FileAttributeInfo(__builtin__.object):
-

Ancestry

+-- __builtin__.object
+gio.FileAttributeInfo

gio.FileAttributeInfo

gio.FileAttributeInfo — Information about a specific attribute.

Synopsis

class gio.FileAttributeInfo(__builtin__.object):
+

Ancestry

+-- __builtin__.object
   +-- gio.FileAttributeInfo
-

Description

+

Description

The gio.FileAttributeInfo contains information about a specific attribute.

gio.FileAttributeInfo Attributes

"name"ReadThe name of the attribute.
"type"Readthe diff --git a/docs/html/class-giofileenumerator.html b/docs/html/class-giofileenumerator.html index 8d276df..23f7edc 100644 --- a/docs/html/class-giofileenumerator.html +++ b/docs/html/class-giofileenumerator.html @@ -1,7 +1,7 @@ -gio.FileEnumerator

gio.FileEnumerator

gio.FileEnumerator — Enumerated Files Routines.

Synopsis

class gio.FileEnumerator(gobject.GObject):
-    def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def get_container()
def has_pending()
def is_closed()
def next_file(cancellable=None)
def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def next_files_finish(result)
def set_pending(pending)

Ancestry

+-- gobject.GObject
+gio.FileEnumerator

gio.FileEnumerator

gio.FileEnumerator — Enumerated Files Routines.

Synopsis

class gio.FileEnumerator(gobject.GObject):
+    def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def get_container()
def has_pending()
def is_closed()
def next_file(cancellable=None)
def next_files_async(num_files, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def next_files_finish(result)
def set_pending(pending)

gio.FileEnumerator Properties

"container"Write - Construct onlyThe container that is being enumerated.

Description

+

gio.FileEnumerator Properties

"container"Write - Construct onlyThe container that is being enumerated.

Description

The gio.FileEnumerator allows you to operate on a set of gio.Files @@ -27,7 +27,7 @@ close_async. Once a gio.FileEnumerator is closed, no further actions may be performed on it. -

Methods

gio.FileEnumerator.close

    def close(cancellable=None)

cancellable :

Optional +

Methods

gio.FileEnumerator.close

    def close(cancellable=None)

cancellable :

Optional gio.Cancellable object, None to ignore.

Returns :

True on success or diff --git a/docs/html/class-giofileicon.html b/docs/html/class-giofileicon.html index e5cdaa6..d211e24 100644 --- a/docs/html/class-giofileicon.html +++ b/docs/html/class-giofileicon.html @@ -1,7 +1,7 @@ -gio.FileIcon

gio.FileIcon

gio.FileIcon — Icons pointing to an image file.

Synopsis

class gio.FileIcon(gobject.GObject, gio.Icon, gio.LoadableIcon):
-    gio.FileIcon(file)
def get_file()

Ancestry

+-- gobject.GObject
+gio.FileIcon

gio.FileIcon

gio.FileIcon — Icons pointing to an image file.

Synopsis

class gio.FileIcon(gobject.GObject, gio.Icon, gio.LoadableIcon):
+    gio.FileIcon(file)
def get_file()

Ancestry

+-- gobject.GObject
   +-- gio.FileIcon
-

Description

+

Description

The gio.FileIcon specifies an icon by pointing to an image file to be used as icon.

Constructor

    gio.FileIcon(file)

file :

a @@ -11,7 +11,7 @@ for the given file, or None on error.

Creates a new icon for a file. -

Methods

gio.FileIcon.get_file

    def get_file()

Returns :

a +

Methods

gio.FileIcon.get_file

    def get_file()

Returns :

a gio.File or None.

diff --git a/docs/html/class-giofileinfo.html b/docs/html/class-giofileinfo.html index 49d5d7b..e888557 100644 --- a/docs/html/class-giofileinfo.html +++ b/docs/html/class-giofileinfo.html @@ -1,7 +1,7 @@ -gio.FileInfo

gio.FileInfo

gio.FileInfo — File Information and Attributes

Synopsis

class gio.FileInfo(gobject.GObject):
-    gio.FileInfo()
def clear_status()
def copy_into()
def dup()
def get_attribute_as_string(attribute)
def get_attribute_boolean(attribute)
def get_attribute_byte_string(attribute)
def get_attribute_data(attribute)
def get_attribute_int32(attribute)
def get_attribute_int64(attribute)
def get_attribute_object(attribute)
def get_attribute_status(attribute)
def get_attribute_string(attribute)
def get_attribute_type(attribute)
def get_attribute_uint32(attribute)
def get_attribute_uint64(attribute)
def get_content_type()
def get_display_name()
def get_edit_name()
def get_etag()
def get_file_type()
def get_icon()
def get_is_backup()
def get_is_hidden()
def get_is_symlink()
def get_modification_time()
def get_name()
def get_size()
def get_sort_order()
def get_symlink_target()
def has_attribute(attribute)
def list_attributes(name_space)
def remove_attribute(attribute)
def set_attribute(attribute, type, value_p)
def set_attribute_boolean(attribute, attr_value)
def set_attribute_byte_string(attribute, attr_value)
def set_attribute_data(attribute, attr_value)
def set_attribute_int32(attribute, attr_value)
def set_attribute_int64(attribute, attr_value)
def set_attribute_mask(mask)
def set_attribute_object(attribute, attr_value)
def set_attribute_status(attribute, attr_value)
def set_attribute_string(attribute, attr_value)
def set_attribute_uint32(attribute)
def set_attribute_uint64(attribute)
def set_content_type(content_type)
def set_display_name(display_name)
def set_edit_name(edit_name)
def set_file_type(type)
def set_icon(icon)
def set_is_hidden(is_hidden)
def set_is_symlink(is_symlink)
def set_modification_time(mtime)
def set_name(name)
def set_size(size)
def set_sort_order(sort_order)
def set_symlink_tarset(symlink_target)
def unset_attribute_mask()

Ancestry

+-- gobject.GObject
+gio.FileInfo

gio.FileInfo

gio.FileInfo — File Information and Attributes

Synopsis

class gio.FileInfo(gobject.GObject):
+    gio.FileInfo()
def clear_status()
def copy_into()
def dup()
def get_attribute_as_string(attribute)
def get_attribute_boolean(attribute)
def get_attribute_byte_string(attribute)
def get_attribute_data(attribute)
def get_attribute_int32(attribute)
def get_attribute_int64(attribute)
def get_attribute_object(attribute)
def get_attribute_status(attribute)
def get_attribute_string(attribute)
def get_attribute_type(attribute)
def get_attribute_uint32(attribute)
def get_attribute_uint64(attribute)
def get_content_type()
def get_display_name()
def get_edit_name()
def get_etag()
def get_file_type()
def get_icon()
def get_is_backup()
def get_is_hidden()
def get_is_symlink()
def get_modification_time()
def get_name()
def get_size()
def get_sort_order()
def get_symlink_target()
def has_attribute(attribute)
def list_attributes(name_space)
def remove_attribute(attribute)
def set_attribute(attribute, type, value_p)
def set_attribute_boolean(attribute, attr_value)
def set_attribute_byte_string(attribute, attr_value)
def set_attribute_data(attribute, attr_value)
def set_attribute_int32(attribute, attr_value)
def set_attribute_int64(attribute, attr_value)
def set_attribute_mask(mask)
def set_attribute_object(attribute, attr_value)
def set_attribute_status(attribute, attr_value)
def set_attribute_string(attribute, attr_value)
def set_attribute_uint32(attribute)
def set_attribute_uint64(attribute)
def set_content_type(content_type)
def set_display_name(display_name)
def set_edit_name(edit_name)
def set_file_type(type)
def set_icon(icon)
def set_is_hidden(is_hidden)
def set_is_symlink(is_symlink)
def set_modification_time(mtime)
def set_name(name)
def set_size(size)
def set_sort_order(sort_order)
def set_symlink_tarset(symlink_target)
def unset_attribute_mask()

Ancestry

+-- gobject.GObject
   +-- gio.FileInfo
-

Description

+

Description

Functionality for manipulating basic metadata for files. gio.FileInfo implements methods for getting information that all files should contain, @@ -39,4 +39,4 @@ gio.FileInfo

Creates a new gio.FileInfo -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-giofileinputstream.html b/docs/html/class-giofileinputstream.html index e9fe926..fe7718e 100644 --- a/docs/html/class-giofileinputstream.html +++ b/docs/html/class-giofileinputstream.html @@ -1,12 +1,12 @@ -gio.FileInputStream

gio.FileInputStream

gio.FileInputStream — Base class for implementing streaming input

Synopsis

class gio.FileInputStream(gio.InputStream):
-    def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Ancestry

+-- gobject.GObject
+gio.FileInputStream

gio.FileInputStream

gio.FileInputStream — Base class for implementing streaming input

Synopsis

class gio.FileInputStream(gio.InputStream):
+    def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Implemented Interfaces

+

Implemented Interfaces

gio.FileInputStream implements gio.Seekable -

Description

+

Description

gio.FileInputStream provides input streams that take their content from a file.

@@ -21,7 +21,7 @@ gio.Seekable.can_seek(). To position a file input stream, use gio.Seekable.seek(). -

Methods

gio.FileInputStream.query_info

    def query_info(attributes, cancellable=None)

attributes :

a file attribute query string. +

Methods

gio.FileInputStream.query_info

    def query_info(attributes, cancellable=None)

attributes :

a file attribute query string.

cancellable :

optional gio.Cancellable object, None to ignore. diff --git a/docs/html/class-giofilemonitor.html b/docs/html/class-giofilemonitor.html index 523cc9e..0ee0fa8 100644 --- a/docs/html/class-giofilemonitor.html +++ b/docs/html/class-giofilemonitor.html @@ -1,12 +1,12 @@ -gio.FileMonitor

gio.FileMonitor

gio.FileMonitor — File Monitor

Synopsis

class gio.FileMonitor(gobject.GObject):
-    def cancel()
def emit_event(child, other_file, event_type)
def is_cancelled()
def set_rate_limit(limit_msecs)

Ancestry

+-- gobject.GObject
+gio.FileMonitor

gio.FileMonitor

gio.FileMonitor — File Monitor

Synopsis

class gio.FileMonitor(gobject.GObject):
+    def cancel()
def emit_event(child, other_file, event_type)
def is_cancelled()
def set_rate_limit(limit_msecs)

gio.FileMonitor Properties

"cancelled"Read Whether the monitor has been cancelled. Default value: False.
"rate-limit"Read/Write The limit of the monitor to watch for changes, in milliseconds. Allowed values: >= 0. Default value: 800. -

gio.FileMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(filemonitor, file, other_file, event_type, user_param1, ...)

Description

+

gio.FileMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(filemonitor, file, other_file, event_type, user_param1, ...)

Description

The gio.FileMonitor monitors a file or directory for changes.

@@ -18,4 +18,4 @@

To get informed about changes to the file or directory you are monitoring, connect to the "changed" signal. -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-giofileoutputstream.html b/docs/html/class-giofileoutputstream.html index 7ef0ad5..26603fd 100644 --- a/docs/html/class-giofileoutputstream.html +++ b/docs/html/class-giofileoutputstream.html @@ -1,12 +1,12 @@ -gio.FileOutputStream

gio.FileOutputStream

gio.FileOutputStream — Base class for implementing streaming input

Synopsis

class gio.FileOutputStream(gio.OutputStream):
-    def get_etag()
def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Ancestry

+-- gobject.GObject
+gio.FileOutputStream

gio.FileOutputStream

gio.FileOutputStream — Base class for implementing streaming input

Synopsis

class gio.FileOutputStream(gio.OutputStream):
+    def get_etag()
def query_info(attributes, cancellable=None)
def query_info_async(attributes, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def query_info_finish(result)

Implemented Interfaces

+

Implemented Interfaces

gio.FileOutputStream implements gio.Seekable -

Description

+

Description

gio.FileOutputStream provides output streams that write their content to a file.

@@ -26,7 +26,7 @@ gio.FileOutputStream.can_truncate(). To truncate a file output stream, use gio.Seekable.truncate(). -

Methods

gio.FileOutputStream.get_etag

    def get_etag()

Returns :

the entity tag for the stream. +

Methods

gio.FileOutputStream.get_etag

    def get_etag()

Returns :

the entity tag for the stream.

The get_etag() method gets the entity tag for the file when it has been written. This must be called after the diff --git a/docs/html/class-giofilterinputstream.html b/docs/html/class-giofilterinputstream.html index ebdfb0d..2c667de 100644 --- a/docs/html/class-giofilterinputstream.html +++ b/docs/html/class-giofilterinputstream.html @@ -1,11 +1,11 @@ -gio.FilterInputStream

gio.FilterInputStream

gio.FilterInputStream — Filter Input Stream

Synopsis

class gio.FilterInputStream(gio.InputStream):
-    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

Ancestry

+-- gobject.GObject
+gio.FilterInputStream

gio.FilterInputStream

gio.FilterInputStream — Filter Input Stream

Synopsis

class gio.FilterInputStream(gio.InputStream):
+    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

gio.FilterInputStream Properties

"base-stream"Read - Write - Construct onlyThe underlying base stream on which the io ops will be done.
"close-base-stream"Read - Write - Construct onlyIf the base stream should be closed when the filter stream is closed. - Default value: True.

Description

+ Default value: True.

Description

Filter Input Stream. -

Methods

gio.FilterInputStream.get_base_stream

    def get_base_stream()

Returns :

A +

Methods

gio.FilterInputStream.get_base_stream

    def get_base_stream()

Returns :

A gio.InputStream

The get_base_stream() method gets the base diff --git a/docs/html/class-giofilteroutputstream.html b/docs/html/class-giofilteroutputstream.html index 8653c9e..a637367 100644 --- a/docs/html/class-giofilteroutputstream.html +++ b/docs/html/class-giofilteroutputstream.html @@ -1,11 +1,11 @@ -gio.FilterOutputStream

gio.FilterOutputStream

gio.FilterOutputStream — Filter Output Stream

Synopsis

class gio.FilterOutputStream(gio.OutputStream):
-    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

Ancestry

+-- gobject.GObject
+gio.FilterOutputStream

gio.FilterOutputStream

gio.FilterOutputStream — Filter Output Stream

Synopsis

class gio.FilterOutputStream(gio.OutputStream):
+    def get_base_stream()
def get_close_base_stream()
def set_close_base_stream(close_base)

gio.FilterOutputStream Properties

"base-stream"Read - Write - Construct onlyThe underlying base stream on which the io ops will be done.
"close-base-stream"Read - Write - Construct onlyIf the base stream should be closed when the filter stream is closed. - Default value: True.

Description

+ Default value: True.

Description

Filter Output Stream. -

Methods

gio.FilterOutputStream.get_base_stream

    def get_base_stream()

Returns :

A +

Methods

gio.FilterOutputStream.get_base_stream

    def get_base_stream()

Returns :

A gio.OutputStream

The get_base_stream() method gets the base diff --git a/docs/html/class-gioicon.html b/docs/html/class-gioicon.html index aed7157..27dcb22 100644 --- a/docs/html/class-gioicon.html +++ b/docs/html/class-gioicon.html @@ -1,19 +1,19 @@ -gio.Icon

gio.Icon

gio.Icon — Interface for icons.

Synopsis

class gio.Icon(gobject.GInterface):
+gio.Icon

gio.Icon

gio.Icon — Interface for icons.

Synopsis

class gio.Icon(gobject.GInterface):
     def equal(icon2)
def to_string()
 Functions
  
-    def gio.icon_new_from_string()

Ancestry

+-- gobject.GInterface
   +-- gio.Icon
-

Known Derived Interfaces

+

Known Derived Interfaces

gio.Icon is required by gio.LoadableIcon. -

Known Implementation

+

Known Implementation

gio.Icon is implemented by gio.ThemedIcon, gio.FileIcon, gio.Emblem, gio.EmblemedIcon. -

Description

+

Description

gio.Icon is a very minimal interface for icons. It provides functions for checking the equality of two icons, hashing of icons and serializing an icon to and from strings. @@ -39,7 +39,7 @@ implementations you need to ensure that each GType is registered with the type system prior to calling gio.icon_new_from_string(). -

Methods

gio.Icon.equal

    def equal(icon2)

icon2 :

the second +

Methods

gio.Icon.equal

    def equal(icon2)

icon2 :

the second gio.Icon

The equal() method checks if two icons are equal. @@ -63,7 +63,7 @@

If icon is a gio.ThemedIcon with exactly one name, the encoding is simply the name (such as network-server). -

Functions

gio.icon_new_from_string

    def icon_new_from_string(str)

str :

A string obtained via +

Functions

gio.icon_new_from_string

    def icon_new_from_string(str)

str :

A string obtained via gio.Icon.to_string().

Returns :

An object implementing the gio.Icon diff --git a/docs/html/class-gioinputstream.html b/docs/html/class-gioinputstream.html index bb06b9b..a2f84bd 100644 --- a/docs/html/class-gioinputstream.html +++ b/docs/html/class-gioinputstream.html @@ -1,7 +1,7 @@ -gio.InputStream

gio.InputStream

gio.InputStream — Base class for implementing streaming input

Synopsis

class gio.InputStream(gobject.GObject):
-    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def has_pending()
def is_closed()
def read(count=-1, cancellable=None)
def read_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result)
def read_part(count=-1, cancellable=None)
def set_pending()
def skip(count, cancellable=None)
def skip_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def skip_finish(result)

Ancestry

+-- gobject.GObject
+gio.InputStream

gio.InputStream

gio.InputStream — Base class for implementing streaming input

Synopsis

class gio.InputStream(gobject.GObject):
+    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def has_pending()
def is_closed()
def read(count=-1, cancellable=None)
def read_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def read_finish(result)
def read_part(count=-1, cancellable=None)
def set_pending()
def skip(count, cancellable=None)
def skip_async(count, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def skip_finish(result)

Description

+

Description

gio.InputStream has functions to read from a stream ( gio.InputStream.read() @@ -16,7 +16,7 @@ gio.OutputStream.splice().

All of these functions have async variants too. -

Methods

gio.InputStream.clear_pending

    def clear_pending()

+

Methods

gio.InputStream.clear_pending

    def clear_pending()

The clear_pending() method clears the pending flag on stream.

gio.InputStream.close

    def close(cancellable=None)

cancellable :

optional gio.Cancellable diff --git a/docs/html/class-gioloadableicon.html b/docs/html/class-gioloadableicon.html index b894302..29cf29d 100644 --- a/docs/html/class-gioloadableicon.html +++ b/docs/html/class-gioloadableicon.html @@ -1,18 +1,18 @@ -gio.LoadableIcon

gio.LoadableIcon

gio.LoadableIcon — Interface for icons.

Synopsis

class gio.LoadableIcon(gobject.GInterface):
-    def load(size=0, cancellable=None)
def load_async(callback, size=0, cancellable=None, user_data=None)
def load_finish(res)

Ancestry

+-- gobject.GInterface
+gio.LoadableIcon

gio.LoadableIcon

gio.LoadableIcon — Interface for icons.

Synopsis

class gio.LoadableIcon(gobject.GInterface):
+    def load(size=0, cancellable=None)
def load_async(callback, size=0, cancellable=None, user_data=None)
def load_finish(res)

Prerequisites

+

Prerequisites

gio.LoadableIcon requires gio.Icon. and gobject.GObject -

Known Implementation

+

Known Implementation

gio.LoadableIcon is implemented by gio.FileIcon -

Description

+

Description

gio.LoadableIcon extends the gio.Icon interface and adds the ability to load icons from streams. -

Methods

gio.LoadableIcon.load

    def load(size=0, cancellable=None)

size :

an integer +

Methods

gio.LoadableIcon.load

    def load(size=0, cancellable=None)

size :

an integer

cancellable :

optional gio.Cancellable object, None to ignore. diff --git a/docs/html/class-giomemoryinputstream.html b/docs/html/class-giomemoryinputstream.html index b9276a9..1029352 100644 --- a/docs/html/class-giomemoryinputstream.html +++ b/docs/html/class-giomemoryinputstream.html @@ -1,15 +1,15 @@ -gio.MemoryInputStream

gio.MemoryInputStream

gio.MemoryInputStream — Base class for implementing streaming input

Synopsis

class gio.MemoryInputStream(gio.InputStream):
+gio.MemoryInputStream

gio.MemoryInputStream

gio.MemoryInputStream — Base class for implementing streaming input

Synopsis

class gio.MemoryInputStream(gio.InputStream):
     gio.MemoryInputStream()
def add_data(data)
 Functions
  
-    def gio.memory_input_stream_new_from_data(data)

Implemented Interfaces

+

Implemented Interfaces

gio.MemoryInputStream implements gio.Seekable -

Description

+

Description

gio.MemoryInputStream is a class for using arbitrary memory chunks as input for GIO streaming input operations.

Constructor

    gio.MemoryInputStream(icon)

Returns :

a new @@ -17,11 +17,11 @@

Creates an empty gio.MemoryInputStream. -

Methods

gio.MemoryInputStream.add_data

    def add_data(data)

data :

input data. +

Methods

gio.MemoryInputStream.add_data

    def add_data(data)

data :

input data.

The add_data() method appends data to data that can be read from the input stream -

Functions

gio.memory_input_stream_new_from_data

    def memory_input_stream_new_from_data(data)

data :

input data. +

Functions

gio.memory_input_stream_new_from_data

    def memory_input_stream_new_from_data(data)

data :

input data.

Returns :

A new gio.MemoryInputStream read from data diff --git a/docs/html/class-giomemoryoutputstream.html b/docs/html/class-giomemoryoutputstream.html index cebe8e3..78c847b 100644 --- a/docs/html/class-giomemoryoutputstream.html +++ b/docs/html/class-giomemoryoutputstream.html @@ -1,12 +1,12 @@ -gio.MemoryOutputStream

gio.MemoryOutputStream

gio.MemoryOutputStream — Streaming output operations on memory chunks

Synopsis

class gio.MemoryOutputStream(gio.OutputStream):
-    gio.MemoryOutputStream()
def get_contents()
def get_data_size()
def get_size()

Ancestry

+-- gobject.GObject
+gio.MemoryOutputStream

gio.MemoryOutputStream

gio.MemoryOutputStream — Streaming output operations on memory chunks

Synopsis

class gio.MemoryOutputStream(gio.OutputStream):
+    gio.MemoryOutputStream()
def get_contents()
def get_data_size()
def get_size()

Implemented Interfaces

+

Implemented Interfaces

gio.MemoryOutputStream implements gio.Seekable -

Description

+

Description

gio.MemoryOutputStream is a class for using arbitrary memory chunks as output for GIO streaming output operations.

Constructor

    gio.MemoryOutputStream()

Returns :

a new @@ -14,7 +14,7 @@

Creates a new gio.MemoryOutputStream. -

Methods

gio.MemoryOutputStream.get_contents

    def get_contents()

Returns :

the stream's data +

Methods

gio.MemoryOutputStream.get_contents

    def get_contents()

Returns :

the stream's data

The get_contents() method gets any loaded data from the ostream. diff --git a/docs/html/class-giomount.html b/docs/html/class-giomount.html index 5486311..9788353 100644 --- a/docs/html/class-giomount.html +++ b/docs/html/class-giomount.html @@ -1,10 +1,10 @@ -gio.Mount

gio.Mount

gio.Mount — Mount management

Synopsis

class gio.Mount(gobject.GInterface):
-    def can_eject()
def can_unmount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def get_drive()
def get_icon()
def get_name()
def get_root()
def get_uuid()
def get_volume()
def guess_content_type(callback, force_rescan, cancellable=None, user_data=None)
def guess_content_type_finish(result)
def guess_content_type_sync(force_rescan, cancellable=None)
def is_shadowed()
def remount(callback, flags=gio.MOUNT_UNMOUNT_NONE, mount_operation=None, cancellable=None, user_data=None)
def remount_finish(result)
def shadow()
def unmount(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_finish(result)
def unshadow()

Ancestry

+-- gobject.GInterface
+gio.Mount

gio.Mount

gio.Mount — Mount management

Synopsis

class gio.Mount(gobject.GInterface):
+    def can_eject()
def can_unmount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def get_drive()
def get_icon()
def get_name()
def get_root()
def get_uuid()
def get_volume()
def guess_content_type(callback, force_rescan, cancellable=None, user_data=None)
def guess_content_type_finish(result)
def guess_content_type_sync(force_rescan, cancellable=None)
def is_shadowed()
def remount(callback, flags=gio.MOUNT_UNMOUNT_NONE, mount_operation=None, cancellable=None, user_data=None)
def remount_finish(result)
def shadow()
def unmount(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def unmount_finish(result)
def unshadow()

Ancestry

+-- gobject.GInterface
   +-- gio.Mount
-

Prerequisites

+

Prerequisites

gio.Mount requires gobject.GObject -

gio.Mount Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mount, user_param1, ...)

"changed"

def callback(mount, user_param1, ...)

"unmounted"

def callback(mount, user_param1, ...)

Description

+

gio.Mount Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mount, user_param1, ...)

"changed"

def callback(mount, user_param1, ...)

"unmounted"

def callback(mount, user_param1, ...)

Description

The gio.Mount interface represents user-visible mounts. Note, when porting from GnomeVFS, gio.Mount @@ -28,7 +28,7 @@ with the GMount and the GAsyncReady data to see if the operation was completed successfully. If an error is present when g_mount_unmount_finish() is called, then it will be filled with any error information. -

Methods

gio.Mount.can_eject

    def can_eject()

Returns :

True if the mount can be ejected, +

Methods

gio.Mount.can_eject

    def can_eject()

Returns :

True if the mount can be ejected, False otherwise.

The can_eject() method checks if a mount can be ejected. @@ -108,7 +108,7 @@

The guess_content_type_finish() method finishes guessing content types of mount. If any errors occured during the operation, error will be set to - contain the errors and FALSE will be returned. In particular, you may get an + contain the errors and False will be returned. In particular, you may get an gio.ERROR_NOT_SUPPORTED if the mount does not support content guessing.

gio.Mount.guess_content_type_sync

    def guess_content_type_sync(force_rescan, cancellable=None)

force_rescan :

Whether to force a rescan of the content. Otherwise a cached result will be used if available.

cancellable :

Optional @@ -221,7 +221,7 @@ gio.Mount.is_shadowed() for more information. The caller will need to emit the "changed" signal on mount manually. -

Signals

The "aborted" gio.Mount Signal

    def callback(mount, user_param1, ...)

mount :

the mount

user_param1 :

the first user parameter (if any) specified +

Signals

The "aborted" gio.Mount Signal

    def callback(mount, user_param1, ...)

mount :

the mount

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted by the backend when e.g. a device becomes unavailable while a diff --git a/docs/html/class-giomountoperation.html b/docs/html/class-giomountoperation.html index 19cc014..491f6bb 100644 --- a/docs/html/class-giomountoperation.html +++ b/docs/html/class-giomountoperation.html @@ -1,5 +1,5 @@ -gio.MountOperation

gio.MountOperation

gio.MountOperation — Authentication methods for mountable locations.

Synopsis

class gio.MountOperation(gobject.GObject):
-    gio.MountOperation()
def get_anonymous()
def get_choice()
def get_domain()
def get_password()
def get_password_save()
def get_username()
def replay(result)
def set_anonymous(anonymous)
def set_choice(choice)
def set_domain(domain)
def set_password(password)
def set_password_save(save)
def set_username(username)

Ancestry

+-- gobject.GObject
+gio.MountOperation

gio.MountOperation

gio.MountOperation — Authentication methods for mountable locations.

Synopsis

class gio.MountOperation(gobject.GObject):
+    gio.MountOperation()
def get_anonymous()
def get_choice()
def get_domain()
def get_password()
def get_password_save()
def get_username()
def replay(result)
def set_anonymous(anonymous)
def set_choice(choice)
def set_domain(domain)
def set_password(password)
def set_password_save(save)
def set_username(username)

gio.MountOperation Properties

"anonymous"Read/Write Whether to use an anonymous user when authenticating. @@ -19,7 +19,7 @@
"username"Read/Write The user name that is used for authentication when carrying out the mount operation. Default value: None -

gio.MountOperation Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mountoperation, user_param1, ...)

"ask-password"

def callback(mountoperation, message, default_user, default_domain, flags, user_param1, ...)

"ask-question"

def callback(mountoperation, message, choices, user_param1, ...)

"reply"

def callback(mountoperation, result, user_param1, ...)

Description

+

gio.MountOperation Signal Prototypes

gobject.GObject Signal Prototypes

"aborted"

def callback(mountoperation, user_param1, ...)

"ask-password"

def callback(mountoperation, message, default_user, default_domain, flags, user_param1, ...)

"ask-question"

def callback(mountoperation, message, choices, user_param1, ...)

"reply"

def callback(mountoperation, result, user_param1, ...)

Description

The gio.MountOperation provides a mechanism for authenticating mountable operations, such as loop mounting files, hard drive partitions or server locations. @@ -37,7 +37,7 @@ gio.MountOperation.

Creates a new mount operation. -

Methods

gio.MountOperation.get_anonymous

    def get_anonymous()

Returns :

True if mount operation is anonymous. +

Methods

gio.MountOperation.get_anonymous

    def get_anonymous()

Returns :

True if mount operation is anonymous.

The get_anonymous() method check to see whether the mount operation is being used for an anonymous user @@ -92,7 +92,7 @@

The set_anonymous() method sets the user name within op to username. -

Signals

The "aborted" gio.MountOperation Signal

    def callback(mountoperation, user_param1, ...)

mountoperation :

the mountoperation

user_param1 :

the first user parameter (if any) specified +

Signals

The "aborted" gio.MountOperation Signal

    def callback(mountoperation, user_param1, ...)

mountoperation :

the mountoperation

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted by the backend when e.g. a device becomes unavailable while a mount operation is in progress. diff --git a/docs/html/class-giooutputstream.html b/docs/html/class-giooutputstream.html index 10b06d9..ac1c691 100644 --- a/docs/html/class-giooutputstream.html +++ b/docs/html/class-giooutputstream.html @@ -1,7 +1,7 @@ -gio.OutputStream

gio.OutputStream

gio.OutputStream — Base class for implementing streaming input

Synopsis

class gio.OutputStream(gobject.GObject):
-    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def flush(cancellable=None)
def flush_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def flush_finish(result)
def has_pending()
def is_closed()
def set_pending()
def splice(cancellable=None, flags=gio.OUTPUT_STREAM_SPLICE_NONE)
def splice_async(source, callback, flags=gio.OUTPUT_STREAM_SPLICE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def splice_finish(result)
def write(buffer, cancellable=None)
def write_async(buffer, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def write_finish(result)

Ancestry

+-- gobject.GObject
+gio.OutputStream

gio.OutputStream

gio.OutputStream — Base class for implementing streaming input

Synopsis

class gio.OutputStream(gobject.GObject):
+    def clear_pending()
def close(cancellable=None)
def close_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def close_finish(result)
def flush(cancellable=None)
def flush_async(callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def flush_finish(result)
def has_pending()
def is_closed()
def set_pending()
def splice(cancellable=None, flags=gio.OUTPUT_STREAM_SPLICE_NONE)
def splice_async(source, callback, flags=gio.OUTPUT_STREAM_SPLICE_NONE, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def splice_finish(result)
def write(buffer, cancellable=None)
def write_async(buffer, callback, io_priority=glib.PRIORITY_DEFAULT, cancellable=None, user_data=None)
def write_finish(result)

Description

+

Description

gio.OutputStream has functions to write from a stream ( gio.OutputStream.write() @@ -16,4 +16,4 @@ gio.OutputStream.splice().

All of these functions have async variants too. -

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

+

Methods

Unfinished section, you may want to see the relevant C API docs for methods descriptions.

diff --git a/docs/html/class-gioseekable.html b/docs/html/class-gioseekable.html index 8e98b67..3a746f5 100644 --- a/docs/html/class-gioseekable.html +++ b/docs/html/class-gioseekable.html @@ -1,19 +1,19 @@ -gio.Seekable

gio.Seekable

gio.Seekable — Stream seeking interface.

Synopsis

class gio.Seekable(gobject.GInterface):
-    def tell()
def can_seek()
def seek(offset, type=0, cancellable=None)
def can_truncate()
def truncate(offset, cancellable=None)

Ancestry

+-- gobject.GInterface
+gio.Seekable

gio.Seekable

gio.Seekable — Stream seeking interface.

Synopsis

class gio.Seekable(gobject.GInterface):
+    def tell()
def can_seek()
def seek(offset, type=0, cancellable=None)
def can_truncate()
def truncate(offset, cancellable=None)

Known Implementation

+

Description

+

Description

gio.Seekable is implemented by streams (implementations of gio.InputStream or gio.OutputStream) that support seeking. -

Methods

gio.Seekable.tell

    def tell()

Returns :

+

Methods

gio.Seekable.tell

    def tell()

Returns :

the offset from the beginning of the buffer

Tells the current position within the stream. diff --git a/docs/html/class-giosimpleasyncresult.html b/docs/html/class-giosimpleasyncresult.html index a9a07fe..fc10409 100644 --- a/docs/html/class-giosimpleasyncresult.html +++ b/docs/html/class-giosimpleasyncresult.html @@ -1,10 +1,10 @@ -gio.SimpleAsyncResult

gio.SimpleAsyncResult

gio.SimpleAsyncResult — Simple asynchronous results implementation.

Synopsis

class gio.SimpleAsyncResult(gobject.GObject):
-    def complete()
def complete_in_idle()
def get_op_res_gboolean()
def get_op_res_gssize()
def propagate_error()
def set_handle_cancellation(handle_cancellation)
def set_op_res_gboolean(op_res)
def set_op_res_gssize(op_res)

Ancestry

+-- gobject.GObject
+gio.SimpleAsyncResult

gio.SimpleAsyncResult

gio.SimpleAsyncResult — Simple asynchronous results implementation.

Synopsis

class gio.SimpleAsyncResult(gobject.GObject):
+    def complete()
def complete_in_idle()
def get_op_res_gboolean()
def get_op_res_gssize()
def propagate_error()
def set_handle_cancellation(handle_cancellation)
def set_op_res_gboolean(op_res)
def set_op_res_gssize(op_res)

Implemented Interface

+

Implemented Interface

gio.SimpleAsyncResult implements gio.AsyncResult. -

Description

+

Description

Implements gio.AsyncResult for simple cases. Most of the time, this will be all an application needs, and will be used transparently Because of this, GSimpleAsyncResult is used throughout GIO for handling asynchronous functions. @@ -49,7 +49,7 @@ gio.SimpleAsyncResult.get_op_res_gboolean() and gio.SimpleAsyncResult.get_op_res_gssize() are provided, getting the operation's result as a gboolean and gssize, respectively. -

Methods

gio.SimpleAsyncResult.complete

    def complete()

+

Methods

gio.SimpleAsyncResult.complete

    def complete()

The complete() method completes an asynchronous I/O job. Must be called in the main thread, as it invokes the callback that should be called in the main thread. If you are in a different thread use diff --git a/docs/html/class-giothemedicon.html b/docs/html/class-giothemedicon.html index 6c2991d..819fe64 100644 --- a/docs/html/class-giothemedicon.html +++ b/docs/html/class-giothemedicon.html @@ -1,5 +1,5 @@ -gio.ThemedIcon

gio.ThemedIcon

gio.ThemedIcon — Icon theming support.

Synopsis

class gio.ThemedIcon(gobject.GObject):
-    gio.ThemedIcon()
def append_name()
def get_names()
def prepend_name()

Ancestry

+-- gobject.GObject
+gio.ThemedIcon

gio.ThemedIcon

gio.ThemedIcon — Icon theming support.

Synopsis

class gio.ThemedIcon(gobject.GObject):
+    gio.ThemedIcon()
def append_name()
def get_names()
def prepend_name()

gio.ThemedIcon Properties

"name"Write/Contruct Only The icon name. Default value: None @@ -9,7 +9,7 @@ Whether to use the default fallbacks found by shortening the icon name at '-' characters. If the "names" array has more than one element, ignores any past the first. -

Description

+

Description

gio.ThemedIcon is an implementation of gio.Icon that supports icon themes. GThemedIcon contains a list of all of the icons present in an icon @@ -27,7 +27,7 @@ Creates a new themed icon from icon name, if instead of an icon name you provide a list of icon names, the gio.ThemedIcon will be constructed using the items in the list. -

Methods

gio.ThemedIcon.append_name

    def append_name()

name :

name of icon to append to list of icons from within icon. +

Methods

gio.ThemedIcon.append_name

    def append_name()

name :

name of icon to append to list of icons from within icon.

The append_name() method appends a name to the list of icons from within icon. diff --git a/docs/html/class-giounixinputstream.html b/docs/html/class-giounixinputstream.html index dce3d2f..d8afe3a 100644 --- a/docs/html/class-giounixinputstream.html +++ b/docs/html/class-giounixinputstream.html @@ -1,9 +1,9 @@ -gio.unix.InputStream

gio.unix.InputStream

gio.unix.InputStream — Streaming input operations for UNIX file descriptors.

Synopsis

class gio.unix.InputStream(gio.InputStream):
-    gio.unix.InputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

Ancestry

+-- gobject.GObject
+gio.unix.InputStream

gio.unix.InputStream

gio.unix.InputStream — Streaming input operations for UNIX file descriptors.

Synopsis

class gio.unix.InputStream(gio.InputStream):
+    gio.unix.InputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

gio.unix.InputStream Properties

"close-fd"Read - WriteWhether to close the file descriptor when the stream is closed. - Default value: True.
"fd"Read - Write - Construct onlyThe file descriptor that the stream reads from. Default value: -1.

Description

+ Default value: True.

"fd"Read - Write - Construct onlyThe file descriptor that the stream reads from. Default value: -1.

Description

gio.unix.InputStream implements gio.InputStream for reading from a UNIX file descriptor, including asynchronous operations. @@ -22,7 +22,7 @@ from the given fd.

If close_fd is True, the file descriptor will be closed when the stream is closed. -

Methods

gio.unix.InputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done. +

Methods

gio.unix.InputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done.

The get_close_fd() method returns whether the file descriptor of stream will be closed when the stream is closed. diff --git a/docs/html/class-giounixoutputstream.html b/docs/html/class-giounixoutputstream.html index 4093d8f..9ad1c3f 100644 --- a/docs/html/class-giounixoutputstream.html +++ b/docs/html/class-giounixoutputstream.html @@ -1,9 +1,9 @@ -gio.unix.OutputStream

gio.unix.OutputStream

gio.unix.OutputStream — Streaming output operations for UNIX file descriptors.

Synopsis

class gio.unix.OutputStream(gio.OutputStream):
-    gio.unix.OutputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

Ancestry

+-- gobject.GObject
+gio.unix.OutputStream

gio.unix.OutputStream

gio.unix.OutputStream — Streaming output operations for UNIX file descriptors.

Synopsis

class gio.unix.OutputStream(gio.OutputStream):
+    gio.unix.OutputStream(fd, close_fd)
def get_close_fd()
def get_fd()
def set_close_fd(close_fd)

gio.unix.OutputStream Properties

"close-fd"Read - WriteWhether to close the file descriptor when the stream is closed. - Default value: True.
"fd"Read - Write - Construct onlyThe file descriptor that the stream writes to. Default value: -1.

Description

+ Default value: True.

"fd"Read - Write - Construct onlyThe file descriptor that the stream writes to. Default value: -1.

Description

gio.unix.OutputStream implements gio.OutputStream for writing to a UNIX file descriptor, including asynchronous operations. @@ -22,7 +22,7 @@ from the given fd.

If close_fd is True, the file descriptor will be closed when the stream is closed. -

Methods

gio.unix.OutputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done. +

Methods

gio.unix.OutputStream.get_close_fd

    def get_close_fd()

Returns :

True if the file descriptor is closed when done.

The get_close_fd() method returns whether the file descriptor of stream will be closed when the stream is closed. diff --git a/docs/html/class-giovolume.html b/docs/html/class-giovolume.html index 957cbad..8ddd73a 100644 --- a/docs/html/class-giovolume.html +++ b/docs/html/class-giovolume.html @@ -1,10 +1,10 @@ -gio.Volume

gio.Volume

gio.Volume — Volume management.

Synopsis

class gio.Volume(gobject.GInterface):
-    def can_eject()
def can_mount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_activation_root()
def get_drive()
def get_icon()
def get_identifier()
def get_mount()
def get_name()
def get_uuid()
def mount(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_finish(result)
def should_automount()

Ancestry

+-- gobject.GInterface
+gio.Volume

gio.Volume

gio.Volume — Volume management.

Synopsis

class gio.Volume(gobject.GInterface):
+    def can_eject()
def can_mount()
def eject(callback, flags=gio.MOUNT_UNMOUNT_NONE, cancellable=None, user_data=None)
def eject_finish(result)
def enumerate_identifiers()
def get_activation_root()
def get_drive()
def get_icon()
def get_identifier()
def get_mount()
def get_name()
def get_uuid()
def mount(mount_operation, callback, flags=gio.MOUNT_MOUNT_NONE, cancellable=None, user_data=None)
def mount_finish(result)
def should_automount()

Ancestry

+-- gobject.GInterface
   +-- gio.Volume
-

Prerequisites

+

Prerequisites

gio.Volume requires gobject.GObject -

gio.Volume Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(volume, user_param1, ...)

"removed"

def callback(volume, user_param1, ...)

Description

+

gio.Volume Signal Prototypes

gobject.GObject Signal Prototypes

"changed"

def callback(volume, user_param1, ...)

"removed"

def callback(volume, user_param1, ...)

Description

The gio.Volume interface represents user-visible objects that can be mounted. Note, when porting from GnomeVFS, gio.Volume @@ -39,7 +39,7 @@ "hal-udi", "label", etc. Use gio.Volume.get_identifier() to obtain an identifier for a volume. -

Methods

gio.Volume.can_eject

    def can_eject()

Returns :

True if the volume can be ejected, +

Methods

gio.Volume.can_eject

    def can_eject()

Returns :

True if the volume can be ejected, False otherwise.

The can_eject() method checks if a volume can be ejected. @@ -162,7 +162,7 @@ volume_activation_root.has_prefix(mount_root) || volume_activation_root.equal(mo

The should_automount() method returns whether the volume should be automatically mounted. -

Signals

The "changed" gio.Volume Signal

    def callback(volume, user_param1, ...)

volume :

the volume

user_param1 :

the first user parameter (if any) specified +

Signals

The "changed" gio.Volume Signal

    def callback(volume, user_param1, ...)

volume :

the volume

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted when the volume has been changed. diff --git a/docs/html/class-giovolumemonitor.html b/docs/html/class-giovolumemonitor.html index 697d14f..2d0eafa 100644 --- a/docs/html/class-giovolumemonitor.html +++ b/docs/html/class-giovolumemonitor.html @@ -1,13 +1,13 @@ -gio.VolumeMonitor

gio.VolumeMonitor

gio.VolumeMonitor — Volume Monitor.

Synopsis

class gio.VolumeMonitor(gobject.GObject):
+gio.VolumeMonitor

gio.VolumeMonitor

gio.VolumeMonitor — Volume Monitor.

Synopsis

class gio.VolumeMonitor(gobject.GObject):
     def get_connected_drives()
def get_mount_for_uuid(uuid)
def get_mounts()
def get_volume_for_uuid(uuid)
def get_volumes()
 Functions
-    def gio.volume_monitor_adopt_orphan_mount()
def gio.volume_monitor_get()

gio.VolumeMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"drive-changed"

def callback(volume_monitor, drive, user_param1, ...)

"drive-connected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-disconnected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-eject-button"

def callback(volume_monitor, drive, user_param1, ...)

"mount-added"

def callback(volume_monitor, mount, user_param1, ...)

"mount-changed"

def callback(volume_monitor, mount, user_param1, ...)

"mount-pre-unmount"

def callback(volume_monitor, mount, user_param1, ...)

"mount-removed"

def callback(volume_monitor, mount, user_param1, ...)

"volume-added"

def callback(volume_monitor, volume, user_param1, ...)

"volume-changed"

def callback(volume_monitor, volume, user_param1, ...)

"volume-removed"

def callback(volume_monitor, volume, user_param1, ...)

Description

+

gio.VolumeMonitor Signal Prototypes

gobject.GObject Signal Prototypes

"drive-changed"

def callback(volume_monitor, drive, user_param1, ...)

"drive-connected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-disconnected"

def callback(volume_monitor, drive, user_param1, ...)

"drive-eject-button"

def callback(volume_monitor, drive, user_param1, ...)

"mount-added"

def callback(volume_monitor, mount, user_param1, ...)

"mount-changed"

def callback(volume_monitor, mount, user_param1, ...)

"mount-pre-unmount"

def callback(volume_monitor, mount, user_param1, ...)

"mount-removed"

def callback(volume_monitor, mount, user_param1, ...)

"volume-added"

def callback(volume_monitor, volume, user_param1, ...)

"volume-changed"

def callback(volume_monitor, volume, user_param1, ...)

"volume-removed"

def callback(volume_monitor, volume, user_param1, ...)

Description

The gio.VolumeMonitor is for listing the user interesting devices and volumes on the computer. In other words, what a file selector or file manager would show in a sidebar. -

Methods

gio.VolumeMonitor.get_connected_drives

    def get_connected_drives()

Returns :

a list of connected +

Methods

gio.VolumeMonitor.get_connected_drives

    def get_connected_drives()

Returns :

a list of connected gio.Drive objects.

The get_connected_drives() method gets a list @@ -40,7 +40,7 @@ objects.

The get_volumes() method gets a list of the volumes on the system. -

Functions

gio.volume_monitor_adopt_orphan_mount

    def volume_monitor_adopt_orphan_mount()

Returns :

The gio.Volume +

Functions

gio.volume_monitor_adopt_orphan_mount

    def volume_monitor_adopt_orphan_mount()

Returns :

The gio.Volume object that is the parent for mount or None if no wants to adopt the gio.Mount.

Warning

This method will be deprecated starting from GIO 2.20

@@ -88,7 +88,7 @@

The volume_monitor_get() function gets the volume monitor used by gio. -

Signals

The "drive-changed" gio.Volume Signal

    def callback(volume_monitor, drive, user_param1, ...)

volume_monitor :

the volume monitor

drive :

the drive that changed

user_param1 :

the first user parameter (if any) specified +

Signals

The "drive-changed" gio.Volume Signal

    def callback(volume_monitor, drive, user_param1, ...)

volume_monitor :

the volume monitor

drive :

the drive that changed

user_param1 :

the first user parameter (if any) specified with the connect() method

... :

additional user parameters (if any)

Emitted when a drive changes. diff --git a/docs/html/class-glibmaincontext.html b/docs/html/class-glibmaincontext.html index 071c992..d362f60 100644 --- a/docs/html/class-glibmaincontext.html +++ b/docs/html/class-glibmaincontext.html @@ -1,7 +1,7 @@ glib.MainContext

glib.MainContext

glib.MainContext — an object representing a set of event sources to be handled -in a glib.MainLoop.

Synopsis

class glib.MainContext:
-    glib.MainContext()
def iteration(may_block)
def pending()

Ancestry

+-- glib.MainContext
-

Description

A glib.MainContext +in a glib.MainLoop.

Synopsis

class glib.MainContext:
+    glib.MainContext()
def iteration(may_block)
def pending()

Ancestry

+-- glib.MainContext
+

Description

A glib.MainContext represents a set of event sources that can be run in a single thread. File descriptors (plain files, pipes or sockets) and timeouts are the standard event sources for GTK and PyGTK though @@ -13,17 +13,17 @@ events from lower priority sources. Single iterations of a iteration() method.

Constructor

    glib.MainContext()

Returns :

a new glib.MainContext object.

Creates a new glib.MainContext -object.

Methods

glib.MainContext.iteration

    def iteration()

may_block :

if TRUE the call may block - waiting for an event.

Returns :

TRUE if events were +object.

Methods

glib.MainContext.iteration

    def iteration()

may_block :

if True the call may block + waiting for an event.

Returns :

True if events were dispatched.

The iteration() method runs a single iteration. This involves:

  • checking to see if any associated event sources are ready to be processed;
  • then if no events sources are ready and -may_block is TRUE, waiting for a +may_block is True, waiting for a source to become ready;
  • and finally, dispatching the highest priority events sources that are ready

Note that even when may_block is -TRUE, it is still possible for -iteration() to return FALSE, +True, it is still possible for +iteration() to return False, since the the wait may be interrupted for other reasons than an event source -becoming ready.

glib.MainContext.pending

    def pending()

Returns :

TRUE if events are +becoming ready.

glib.MainContext.pending

    def pending()

Returns :

True if events are pending.

The pending() method checks if any associated sources have pending events.

diff --git a/docs/html/class-glibmainloop.html b/docs/html/class-glibmainloop.html index d0894dc..808da10 100644 --- a/docs/html/class-glibmainloop.html +++ b/docs/html/class-glibmainloop.html @@ -1,7 +1,7 @@ glib.MainLoop

glib.MainLoop

glib.MainLoop — an object representing the main event loop of a PyGTK - application.

Synopsis

class glib.MainLoop:
-    glib.MainLoop(context=None, is_running=0)
def get_context()
def is_running()
def quit()
def run()

Ancestry

+-- glib.MainLoop
-

Description

glib.MainLoop + application.

Synopsis

class glib.MainLoop:
+    glib.MainLoop(context=None, is_running=0)
def get_context()
def is_running()
def quit()
def run()

Ancestry

+-- glib.MainLoop
+

Description

glib.MainLoop represents a main event loop. A glib.MainLoop is created with the glib.MainLoop() constructor. After adding the initial event sources, the run() @@ -19,15 +19,15 @@ functions, e.g. the gtk.events_pending() functions.

Constructor

    glib.MainLoop(context=None, is_running=None)

context :

a glib.MainContext or None to use the default - context.

is_running :

if TRUE indicates that the + context.

is_running :

if True indicates that the loop is running. This is not very important since calling the run() - method will set this to TRUE + method will set this to True anyway.

Returns :

a new glib.MainLoop object.

Creates a new glib.MainLoop -object.

Methods

glib.MainLoop.get_context

    def get_context()

Returns :

the glib.MainContext +object.

Methods

glib.MainLoop.get_context

    def get_context()

Returns :

the glib.MainContext the mainloop is associated with

The get_context() method returns the glib.MainContext -that the mainloop was created with.

glib.MainLoop.is_running

    def is_running()

Returns :

TRUE if the mainloop is +that the mainloop was created with.

glib.MainLoop.is_running

    def is_running()

Returns :

True if the mainloop is currently being run.

The is_running() method checks to see if the mainloop is currently being run via the run() method.

glib.MainLoop.quit

    def quit()

The quit() method stops the mainloop diff --git a/docs/html/class-gobject.html b/docs/html/class-gobject.html index 4c1e07c..b95b7f0 100644 --- a/docs/html/class-gobject.html +++ b/docs/html/class-gobject.html @@ -1,6 +1,6 @@ -gobject.GObject

gobject.GObject

gobject.GObject — the base class

Synopsis

class gobject.GObject:
-    def get_property(property_name)
def get_properties(first_property_name, ...)
def set_property(property_name, value)
def set_properties(property_name=value, ...)
def freeze_notify()
def notify(property_name)
def thaw_notify()
def get_data(key)
def set_data(key, data)
def connect(detailed_signal, handler)
def connect_after(detailed_signal, handler)
def connect_object(detailed_signal, handler)
def connect_object_after(detailed_signal, handler)
def disconnect(handler_id)
def handler_disconnect(handler_id)
def handler_is_connected(handler_id)
def handler_block(handler_id)
def handler_unblock(handler_id)
def handler_block_by_func(callable)
def handler_unblock_by_func(callable)
def emit(detailed_signal)
def stop_emission(detailed_signal)
def emit_stop_by_name(detailed_signal)
def chain()

Ancestry

+-- gobject.GObject
-

Attributes

"props"Read/Write +gobject.GObject

gobject.GObject

gobject.GObject — the base class

Synopsis

class gobject.GObject:
+    def get_property(property_name)
def get_properties(first_property_name, ...)
def set_property(property_name, value)
def set_properties(property_name=value, ...)
def freeze_notify()
def notify(property_name)
def thaw_notify()
def get_data(key)
def set_data(key, data)
def connect(detailed_signal, handler)
def connect_after(detailed_signal, handler)
def connect_object(detailed_signal, handler)
def connect_object_after(detailed_signal, handler)
def disconnect(handler_id)
def handler_disconnect(handler_id)
def handler_is_connected(handler_id)
def handler_block(handler_id)
def handler_unblock(handler_id)
def handler_block_by_func(callable)
def handler_unblock_by_func(callable)
def emit(detailed_signal)
def stop_emission(detailed_signal)
def emit_stop_by_name(detailed_signal)
def chain()

Ancestry

+-- gobject.GObject
+

Attributes

"props"Read/Write

This attribute gives full access to GObject properties as simple attributes. It can be used to iterate over all the object properties, and can be used both on class or instance objects.

@@ -17,12 +17,12 @@ button_label = button.get_property(label_pspec.name)
"__doc__"ReadThe documentation for the object type. Uses "__gdoc__" if no specific documentation set.
"__gdoc__"ReadThe generated documentation for the underlying GObject - type.
"__gtype__"ReadThe underlying GObject type.
"__grefcount__"ReadThe reference count for the underlying GObject.

gobject.GObject Signal Prototypes

"notify"

def callback(gobject, property_spec, user_param1, ...)

Description

The gobject.GObject + type.

"__gtype__"ReadThe underlying GObject type.
"__grefcount__"ReadThe reference count for the underlying GObject.

gobject.GObject Signal Prototypes

"notify"

def callback(gobject, property_spec, user_param1, ...)

Description

The gobject.GObject class is the base class providing the common attributes and methods for the PyGTK classes. The gobject.GObject class is not a user interface widget class.

The gobject.GObject class provides the signal management methods, the object property access - methods and the object data management methods.

Methods

gobject.GObject.get_property

    def get_property(property_name)

property_name :

a string containing the property name for the + methods and the object data management methods.

Methods

gobject.GObject.get_property

    def get_property(property_name)

property_name :

a string containing the property name for the GObject

Returns :

a Python object containing the value of the property

The get_property() method returns the value of the property specified by property_name or @@ -130,9 +130,9 @@ list of signal handlers for the object.

handler_disconnect() method removes the signal handler with the specified handler_id from the list of signal handlers for the object.

gobject.GObject.handler_is_connected

    def handler_is_connected(handler_id)

handler_id :

an integer handler -identifier

Returns :

TRUE if the signal handler +identifier

Returns :

True if the signal handler is connected to the object.

The handler_is_connected() method -returns TRUE if the signal handler with the specified +returns True if the signal handler with the specified handler_id is connected to the object.

gobject.GObject.handler_block

    def handler_block(handler_id)

handler_id :

an integer handler identifier

The handler_block() method blocks the signal handler with the specified handler_id from @@ -161,7 +161,7 @@ still to be run will not be invoked.

emit_stop_by_name() method stops the current emission of the signal specified by detailed_signal. Any signal handlers in the list -still to be run will not be invoked.

gobject.GObject.chain

    def chain(...)

... :

additional parameters

Returns :

a Python object

The chain() method does something.

Signals

The GObject "notify" Signal

    def callback(gobject, property_spec, user_param1, ...)

gobject :

the gobject that received the +still to be run will not be invoked.

gobject.GObject.chain

    def chain(...)

... :

additional parameters

Returns :

a Python object

The chain() method does something.

Signals

The GObject "notify" Signal

    def callback(gobject, property_spec, user_param1, ...)

gobject :

the gobject that received the signal

property_spec :

the gobject.GParamSpec of the property that was changed

user_param1 :

the first user parameter (if any) specified with the connect() diff --git a/docs/html/class-gobjectgboxed.html b/docs/html/class-gobjectgboxed.html index ead5e11..c9aa6f0 100644 --- a/docs/html/class-gobjectgboxed.html +++ b/docs/html/class-gobjectgboxed.html @@ -1,9 +1,9 @@ -gobject.GBoxed

gobject.GBoxed

gobject.GBoxed — an object containing an opaque chunk of data

Synopsis

class gobject.GBoxed:
-    def copy()

Ancestry

+-- gobject.GBoxed
-

Description

gobject.GBoxed +gobject.GBoxed

gobject.GBoxed

gobject.GBoxed — an object containing an opaque chunk of data

Synopsis

class gobject.GBoxed:
+    def copy()

Ancestry

+-- gobject.GBoxed
+

Description

gobject.GBoxed is an abstract base class that encapsulates an opaque chunk of data to provide an object-oriented interface and a type that is registered with the GLIB type system. A boxed type is registered with functions that provide for the copying and freeing of the underlying data -structure - this allows PyGTK to encapsulate these as Python objects.

Methods

gobject.GBoxed.copy

    def copy()

Returns :

a copy of the gobject.GBoxed +structure - this allows PyGTK to encapsulate these as Python objects.

Methods

gobject.GBoxed.copy

    def copy()

Returns :

a copy of the gobject.GBoxed object

The copy() method makes and returns a copy of the boxed object.

diff --git a/docs/html/class-gobjectginterface.html b/docs/html/class-gobjectginterface.html index b15ef7e..a288214 100644 --- a/docs/html/class-gobjectginterface.html +++ b/docs/html/class-gobjectginterface.html @@ -1,4 +1,4 @@ -gobject.GInterface

gobject.GInterface

gobject.GInterface — an object representing a GInterface

Synopsis

class gobject.GInterface:
-

Ancestry

+-- gobject.GInterface
-

Description

gobject.GInterface +gobject.GInterface

gobject.GInterface

gobject.GInterface — an object representing a GInterface

Synopsis

class gobject.GInterface:
+

Ancestry

+-- gobject.GInterface
+

Description

gobject.GInterface is an abstract base class that encapsulates a GInterface.

diff --git a/docs/html/class-gobjectgpointer.html b/docs/html/class-gobjectgpointer.html index 4b86cd9..ced526a 100644 --- a/docs/html/class-gobjectgpointer.html +++ b/docs/html/class-gobjectgpointer.html @@ -1,7 +1,7 @@ gobject.GPointer

gobject.GPointer

gobject.GPointer — an object containing a completely opaque chunk of - data

Synopsis

class gobject.GPointer:
-

Ancestry

+-- gobject.GPointer
-

Description

gobject.GPointer + data

Synopsis

class gobject.GPointer:
+

Ancestry

+-- gobject.GPointer
+

Description

gobject.GPointer is an abstract base class that encapsulates an opaque chunk of data and registers it with the GLIB type system. A pointer type has no methods and generic ways of copying and freeing the data. It diff --git a/docs/html/gio-constants.html b/docs/html/gio-constants.html index b1c8bb2..660e93a 100644 --- a/docs/html/gio-constants.html +++ b/docs/html/gio-constants.html @@ -1,4 +1,4 @@ -gio Constants

gio Constants

gio Constants — the built-in constants of the gio module

Synopsis

+gio Constants

gio Constants

gio Constants — the built-in constants of the gio module

Synopsis

 Gio AppInfo Create Flags Constants
 Gio Ask Password Flags Constants
 Gio Data Stream Byte Order Constants
diff --git a/docs/html/gio-functions.html b/docs/html/gio-functions.html
index 80287e6..f610a98 100644
--- a/docs/html/gio-functions.html
+++ b/docs/html/gio-functions.html
@@ -1,7 +1,7 @@
-gio Functions

gio Functions

gio Functions

Description

+gio Functions

gio Functions

gio Functions

Description

These functions are part of the PyGObject gio module but are not directly associated with a specific class -

Functions

gio.content_type_can_be_executable

    def content_type_can_be_executable(type)

type :

a content type string. +

Functions

gio.content_type_can_be_executable

    def content_type_can_be_executable(type)

type :

a content type string.

Returns :

True if the file type corresponds to a type that can be executable, False otherwise.

diff --git a/docs/html/glib-constants.html b/docs/html/glib-constants.html index fd86c99..9a8519a 100644 --- a/docs/html/glib-constants.html +++ b/docs/html/glib-constants.html @@ -1,4 +1,4 @@ -glib Constants

glib Constants

glib Constants — the built-in constants of the glib module

Synopsis

+glib Constants

glib Constants

glib Constants — the built-in constants of the glib module

Synopsis

 Glib IO Condition Constants
 Glib Priority Constants
 Glib Spawn Flag Constants
diff --git a/docs/html/glib-functions.html b/docs/html/glib-functions.html
index b1f8138..68fcabb 100644
--- a/docs/html/glib-functions.html
+++ b/docs/html/glib-functions.html
@@ -1,6 +1,6 @@
-glib Functions

glib Functions

glib Functions — miscellaneous functions

Synopsis

-    def glib.idle_add(callback, ...)
def glib.timeout_add(interval, callback, ...)
def glib.timeout_add_seconds(interval, callback, ...)
def glib.io_add_watch(fd, condition, callback, ...)
def glib.source_remove(tag)
def glib.main_context_default()
def glib.markup_escape_text(text)
def glib.child_watch_add(pid, function, data=None, priority=glib.PRIORITY_DEFAULT)
def glib.spawn_async(argv, envp=None, working_directory=None, flags=0, child_setup=None, user_data=None, standard_input=None, standard_output=None, standard_error=None)
def glib.get_current_time()
def glib.get_user_cache_dir()
def glib.get_user_config_dir()
def glib.get_user_data_dir()
def glib.get_user_special_dir(directory)
def glib.main_depth()
def glib.threads_init()
def glib.filename_display_name(filename)
def glib.filename_display_basename(filename)
def glib.filename_from_utf8(utf8string)

Description

These functions are part of the PyGObject glib -module but are not directly associated with a specific class.

Functions

glib.idle_add

    def glib.idle_add(callback, ...)

callback :

a function to call when +glib Functions

glib Functions

glib Functions — miscellaneous functions

Synopsis

+    def glib.idle_add(callback, ...)
def glib.timeout_add(interval, callback, ...)
def glib.timeout_add_seconds(interval, callback, ...)
def glib.io_add_watch(fd, condition, callback, ...)
def glib.source_remove(tag)
def glib.main_context_default()
def glib.markup_escape_text(text)
def glib.child_watch_add(pid, function, data=None, priority=glib.PRIORITY_DEFAULT)
def glib.spawn_async(argv, envp=None, working_directory=None, flags=0, child_setup=None, user_data=None, standard_input=None, standard_output=None, standard_error=None)
def glib.get_current_time()
def glib.get_user_cache_dir()
def glib.get_user_config_dir()
def glib.get_user_data_dir()
def glib.get_user_special_dir(directory)
def glib.main_depth()
def glib.threads_init()
def glib.filename_display_name(filename)
def glib.filename_display_basename(filename)
def glib.filename_from_utf8(utf8string)

Description

These functions are part of the PyGObject glib +module but are not directly associated with a specific class.

Functions

glib.idle_add

    def glib.idle_add(callback, ...)

callback :

a function to call when PyGTK is idle

... :

optionals arguments to be passed to callback

Returns :

an integer ID

The glib.idle_add() function adds a function (specified by callback) to be called @@ -10,7 +10,7 @@ loop. The function is given the default idle priority, pass to callback can be specified after callback. The idle priority can be specified as a keyword-value pair with the keyword "priority". If -callback returns FALSE it is +callback returns False it is automatically removed from the list of event sources and will not be called again.

glib.timeout_add

    def glib.timeout_add(interval, callback, ...)

interval :

the time between calls to the function, in milliseconds

callback :

the function to call

... :

zero or more arguments that will be passed to @@ -22,7 +22,7 @@ default priority, glib.PRIORITY_DEFAULT. Additional arguments to pass to callback can be specified after callback. The idle priority may be specified as a keyword-value pair with the keyword "priority".

The function is called repeatedly until it returns -FALSE, at which point the timeout is automatically +False, at which point the timeout is automatically destroyed and the function will not be called again. The first call to the function will be at the end of the first interval. Note that timeout functions may be delayed, due to the processing of other event sources. Thus @@ -67,10 +67,10 @@ signature of the callback function is:

 cb_condition is the condition that triggered the
 signal; and, ... are the zero or more arguments that
 were passed to the glib.io_add_watch()
-function.

If the callback function returns FALSE it +function.

If the callback function returns False it will be automatically removed from the list of event sources and will not be -called again. If it returns TRUE it will be called again -when the condition is matched.

glib.source_remove

    def glib.source_remove(tag)

tag :

an integer ID

Returns :

TRUE if the event source was +called again. If it returns True it will be called again +when the condition is matched.

glib.source_remove

    def glib.source_remove(tag)

tag :

an integer ID

Returns :

True if the event source was removed

The glib.source_remove() function removes the event source specified by tag (as returned by the glib.idle_add(), glib.timeout_add() @@ -102,9 +102,9 @@ of the child process

working_directory :

the child's current working directory, or None to inherit parent's

flags :

flags from the Glib Spawn Flag Constants.

child_setup :

a function to run in the child just before calling exec()

user_data :

the user data for the -child_setup function

standard_input :

if TRUE return the file -descriptor for the child's stdin

standard_output :

if TRUE return the file -descriptor for the child's stdout

standard_error :

if TRUE return the file +child_setup function

standard_input :

if True return the file +descriptor for the child's stdin

standard_output :

if True return the file +descriptor for the child's stdout

standard_error :

if True return the file descriptor for the child's stderr

Returns :

a 4-tuple containing the child's process id and the stdin, stdout and stderr file descriptor integers.

Note

This function is available in PyGTK 2.6 and above.

The glib.spawn_async() function executes a child program asynchronously (your program will not block waiting for the @@ -121,7 +121,7 @@ and stderr. The stdin, stdout and stderr file descriptors are returned only ofthe corresponding standard_input, standard_output or standard_error params are -TRUE.

On Windows, the low-level child process creation API +True.

On Windows, the low-level child process creation API (CreateProcess()) doesn't use argument vectors, but a command line. The C runtime library's spawn*() family of functions (which glib.spawn_async() diff --git a/docs/html/gobject-constants.html b/docs/html/gobject-constants.html index 969e25f..66eada9 100644 --- a/docs/html/gobject-constants.html +++ b/docs/html/gobject-constants.html @@ -1,4 +1,4 @@ -gobject Constants

gobject Constants

gobject Constants — the built-in constants of the gobject module

Synopsis

+gobject Constants

gobject Constants

gobject Constants — the built-in constants of the gobject module

Synopsis

 GObject Param Flag Constants
 GObject Signal Flag Constants
 GObject Built-in Type Constants
diff --git a/docs/html/gobject-functions.html b/docs/html/gobject-functions.html
index 1f76f55..eb53411 100644
--- a/docs/html/gobject-functions.html
+++ b/docs/html/gobject-functions.html
@@ -1,12 +1,12 @@
-gobject Functions

gobject Functions

gobject Functions — miscellaneous functions

Synopsis

+gobject Functions

gobject Functions

gobject Functions — miscellaneous functions

Synopsis

     def gobject.type_name(type)
def gobject.type_from_name(type_name)
def gobject.type_parent(type)
def gobject.type_is_a(type, parent_type)
def gobject.type_children(type)
def gobject.type_interfaces(type)
def gobject.type_register(class)
def gobject.signal_new(signal_name, type, flags, return_type, param_types)
def gobject.signal_list_names(type)
def gobject.signal_list_ids(type)
def gobject.signal_lookup(name, type)
def gobject.signal_name(signal_id)
def gobject.signal_query(name, type)
def gobject.signal_query(signal_id)
def gobject.list_properties(type)
def gobject.new(type, ...)
def gobject.signal_accumulator_true_handled()
def gobject.add_emission_hook(type, name, callback, ...)
def gobject.remove_emission_hook(type, name, hook_id)
def gobject._install_metaclass(metaclass) -

Description

These functions are part of the PyGTK gobject +

Description

These functions are part of the PyGTK gobject module but are not directly associated with a specific class.

Note

Many functions that previously were in this namespace got moved to glib namespace instead. They are still available in gobject for backward compatibility, but not documented here. If you miss documentation for some function, be sure to check glib first. -

Functions

gobject.type_name

    def gobject.type_name(type)

type :

a GObject type, type ID or +

Functions

gobject.type_name

    def gobject.type_name(type)

type :

a GObject type, type ID or instance

Returns :

The gobject.type_name() function returns the unique name that is assigned to the specified type. type can be a GObject @@ -24,12 +24,12 @@ the direct parent type ID of the specified typetype has no parent, i.e. is a fundamental type, the RuntimeError exception is raised.

gobject.type_is_a

    def gobject.type_is_a(type, parent_type)

type :

a GObject type, type ID or instance

parent_type :

a GObject type, type ID or -instance

Returns :

TRUE if +instance

Returns :

True if parent_type is an ancestor of type

The gobject.type_is_a() function returns -TRUE if the specified type is a +True if the specified type is a descendant of the type specified by parent_type. This -function also returns TRUE if +function also returns True if parent_type is an interface and type conforms to it.

gobject.type_children

    def gobject.type_children(type)

type :

a GObject type, type ID or instance

Returns :

a list of the child types of diff --git a/docs/html/index.html b/docs/html/index.html index fe8c44c..f16d04d 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -1,4 +1,4 @@ -PyGObject Reference Manual

PyGObject Reference Manual

for PyGObject version 2.21.2

2010-06-10 +PyGObject Reference Manual

PyGObject Reference Manual

for PyGObject version 2.26.0

2010-09-27

Abstract

This reference describes the classes of the python gobject module.


Table of Contents

Introduction
Reference Page Format
PyGlibClass Reference
glib.MainContext — an object representing a set of event sources to be handled in a glib.MainLoop.
glib.MainLoop — an object representing the main event loop of a PyGTK diff --git a/docs/reference/pygio-mount.xml b/docs/reference/pygio-mount.xml index aa635d4..f01b155 100644 --- a/docs/reference/pygio-mount.xml +++ b/docs/reference/pygio-mount.xml @@ -536,11 +536,12 @@ - + + The guess_content_type_finish() method finishes guessing content types of mount. If any errors occured during the operation, error will be set to - contain the errors and FALSE will be returned. In particular, you may get an + contain the errors and False will be returned. In particular, you may get an gio.ERROR_NOT_SUPPORTED if the mount does not support content guessing. diff --git a/docs/reference/pyglib-functions.xml b/docs/reference/pyglib-functions.xml index 358fa83..3e11251 100644 --- a/docs/reference/pyglib-functions.xml +++ b/docs/reference/pyglib-functions.xml @@ -148,7 +148,7 @@ loop. The function is given the default idle priority, pass to callback can be specified after callback. The idle priority can be specified as a keyword-value pair with the keyword "priority". If -callback returns FALSE it is +callback returns False it is automatically removed from the list of event sources and will not be called again. @@ -194,7 +194,7 @@ arguments to pass to callback can be specified after keyword-value pair with the keyword "priority". The function is called repeatedly until it returns -FALSE, at which point the timeout is automatically +False, at which point the timeout is automatically destroyed and the function will not be called again. The first call to the function will be at the end of the first interval. Note that timeout functions may be delayed, due to the processing of other event sources. Thus @@ -355,9 +355,9 @@ signal; and, ... are the zero or more arguments that were passed to the glib.io_add_watch() function. - If the callback function returns FALSE it + If the callback function returns False it will be automatically removed from the list of event sources and will not be -called again. If it returns TRUE it will be called again +called again. If it returns True it will be called again when the condition is matched. @@ -376,7 +376,7 @@ when the condition is matched. Returns : - TRUE if the event source was + True if the event source was removed @@ -553,17 +553,17 @@ calling exec() standard_input : - if TRUE return the file + if True return the file descriptor for the child's stdin standard_output : - if TRUE return the file + if True return the file descriptor for the child's stdout standard_error : - if TRUE return the file + if True return the file descriptor for the child's stderr @@ -591,7 +591,7 @@ and stderr. The stdin, stdout and stderr file descriptors are returned only ofthe corresponding standard_input, standard_output or standard_error params are -TRUE. +True. On Windows, the low-level child process creation API (CreateProcess()) doesn't use argument vectors, but a diff --git a/docs/reference/pyglib-maincontext.xml b/docs/reference/pyglib-maincontext.xml index ccb91bb..ee1e985 100644 --- a/docs/reference/pyglib-maincontext.xml +++ b/docs/reference/pyglib-maincontext.xml @@ -91,12 +91,12 @@ object. may_block : - if TRUE the call may block + if True the call may block waiting for an event. Returns : - TRUE if events were + True if events were dispatched. @@ -111,7 +111,7 @@ to be processed; then if no events sources are ready and -may_block is TRUE, waiting for a +may_block is True, waiting for a source to become ready; @@ -121,8 +121,8 @@ sources that are ready Note that even when may_block is -TRUE, it is still possible for -iteration() to return FALSE, +True, it is still possible for +iteration() to return False, since the the wait may be interrupted for other reasons than an event source becoming ready. @@ -137,7 +137,7 @@ becoming ready. Returns : - TRUE if events are + True if events are pending. diff --git a/docs/reference/pyglib-mainloop.xml b/docs/reference/pyglib-mainloop.xml index bd12fca..913e743 100644 --- a/docs/reference/pyglib-mainloop.xml +++ b/docs/reference/pyglib-mainloop.xml @@ -101,10 +101,10 @@ functions. is_running : - if TRUE indicates that the + if True indicates that the loop is running. This is not very important since calling the run() - method will set this to TRUE + method will set this to True anyway. @@ -155,7 +155,7 @@ that the mainloop was created with. Returns : - TRUE if the mainloop is + True if the mainloop is currently being run. diff --git a/docs/reference/pygobject-functions.xml b/docs/reference/pygobject-functions.xml index 7ca3918..1f50fbe 100644 --- a/docs/reference/pygobject-functions.xml +++ b/docs/reference/pygobject-functions.xml @@ -233,16 +233,16 @@ instance Returns : - TRUE if + True if parent_type is an ancestor of type The gobject.type_is_a() function returns -TRUE if the specified type is a +True if the specified type is a descendant of the type specified by parent_type. This -function also returns TRUE if +function also returns True if parent_type is an interface and type conforms to it. diff --git a/docs/reference/pygobject.xml b/docs/reference/pygobject.xml index ac41e47..42cd37b 100644 --- a/docs/reference/pygobject.xml +++ b/docs/reference/pygobject.xml @@ -760,13 +760,13 @@ identifier Returns : - TRUE if the signal handler + True if the signal handler is connected to the object. The handler_is_connected() method -returns TRUE if the signal handler with the specified +returns True if the signal handler with the specified handler_id is connected to the object. diff --git a/examples/Makefile.in b/examples/Makefile.in index 1d73750..e749490 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -91,6 +91,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py index 8420c2f..72a0533 100755 --- a/examples/cairo-demo.py +++ b/examples/cairo-demo.py @@ -1,6 +1,8 @@ #!/usr/bin/env python """Based on cairo-demo/X11/cairo-demo.c """ +import pygtk +pygtk.require('2.0') import cairo from gi.repository import Gdk, Gtk @@ -107,7 +109,7 @@ def expose (da, event): def main(): win = Gtk.Window() - win.connect('destroy', Gtk.main_quit) + win.connect('destroy', lambda w: Gtk.main_quit()) win.set_default_size(450, 550) drawingarea = Gtk.DrawingArea() diff --git a/gi/Makefile.am b/gi/Makefile.am index c651c97..2fbb4ac 100644 --- a/gi/Makefile.am +++ b/gi/Makefile.am @@ -7,7 +7,7 @@ SUBDIRS = \ repository \ overrides -INCLUDES = -I$(top_srcdir)/gobject +INCLUDES = -I$(top_srcdir)/gobject -I$(top_srcdir)/glib pygidir = $(pkgpyexecdir)/gi pygi_PYTHON = \ @@ -22,7 +22,7 @@ _gi_la_CFLAGS = \ _gi_la_LDFLAGS = \ -module \ -avoid-version \ - -export-symbols-regex init_gi + -export-symbols-regex "init_gi|PyInit__gi" _gi_la_LIBADD = \ $(GI_LIBS) _gi_la_SOURCES = \ @@ -34,6 +34,8 @@ _gi_la_SOURCES = \ pygi-invoke.h \ pygi-foreign.c \ pygi-foreign.h \ + pygi-foreign-gvariant.c \ + pygi-foreign-gvariant.h \ pygi-struct.c \ pygi-struct.h \ pygi-argument.c \ @@ -48,6 +50,8 @@ _gi_la_SOURCES = \ pygi-callbacks.h \ pygi.h \ pygi-private.h \ + pygi-property.c \ + pygi-property.h \ pygobject-external.h \ gimodule.c @@ -58,24 +62,28 @@ _gi_cairo_la_CFLAGS = \ _gi_cairo_la_LDFLAGS = \ -module \ -avoid-version \ - -export-symbols-regex init_gi_cairo + -export-symbols-regex "init_gi_cairo|PyInit__gi_cairo" _gi_cairo_la_LIBADD = \ $(GI_LIBS) \ $(PYCAIRO_LIBS) _gi_cairo_la_SOURCES = pygi-foreign-cairo.c -pygi_LTLIBRARIES = _gi.la _gi_cairo.la + +pygi_LTLIBRARIES = _gi.la + +if ENABLE_CAIRO +pygi_LTLIBRARIES += _gi_cairo.la +endif + # This is to ensure we have a symlink to the .so in the # build directory, which the Python interpreter can load # directly without having to know how to parse .la files. -_gi.so: _gi.la - rm -f $@ && $(LN_S) .libs/$@ $@ -_gi_cairo.so: _gi_cairo.la - rm -f $@ && $(LN_S) .libs/$@ $@ +.la.so: + test -L $@ || $(LN_S) .libs/$@ $@ -all-local: _gi.so _gi_cairo.so -check-local: _gi.so _gi_cairo.so +all-local: $(LTLIBRARIES:.la=.so) +check-local: $(LTLIBRARIES:.la=.so) clean-local: - rm -f _gi.so _gi_cairo.so + rm -f $(LTLIBRARIES:.la=.so) diff --git a/gi/Makefile.in b/gi/Makefile.in index 6fb0b9a..1aecd0a 100644 --- a/gi/Makefile.in +++ b/gi/Makefile.in @@ -33,6 +33,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +@ENABLE_CAIRO_TRUE@am__append_1 = _gi_cairo.la subdir = gi DIST_COMMON = $(pygi_PYTHON) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in @@ -75,9 +76,10 @@ am__DEPENDENCIES_1 = _gi_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am__gi_la_OBJECTS = _gi_la-pygi-repository.lo _gi_la-pygi-info.lo \ _gi_la-pygi-invoke.lo _gi_la-pygi-foreign.lo \ - _gi_la-pygi-struct.lo _gi_la-pygi-argument.lo \ - _gi_la-pygi-type.lo _gi_la-pygi-boxed.lo \ - _gi_la-pygi-closure.lo _gi_la-pygi-callbacks.lo \ + _gi_la-pygi-foreign-gvariant.lo _gi_la-pygi-struct.lo \ + _gi_la-pygi-argument.lo _gi_la-pygi-type.lo \ + _gi_la-pygi-boxed.lo _gi_la-pygi-closure.lo \ + _gi_la-pygi-callbacks.lo _gi_la-pygi-property.lo \ _gi_la-gimodule.lo _gi_la_OBJECTS = $(am__gi_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) @@ -93,6 +95,7 @@ _gi_cairo_la_OBJECTS = $(am__gi_cairo_la_OBJECTS) _gi_cairo_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(_gi_cairo_la_CFLAGS) \ $(CFLAGS) $(_gi_cairo_la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_CAIRO_TRUE@am__gi_cairo_la_rpath = -rpath $(pygidir) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -199,6 +202,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ @@ -323,7 +327,7 @@ SUBDIRS = \ repository \ overrides -INCLUDES = -I$(top_srcdir)/gobject +INCLUDES = -I$(top_srcdir)/gobject -I$(top_srcdir)/glib pygidir = $(pkgpyexecdir)/gi pygi_PYTHON = \ types.py \ @@ -338,7 +342,7 @@ _gi_la_CFLAGS = \ _gi_la_LDFLAGS = \ -module \ -avoid-version \ - -export-symbols-regex init_gi + -export-symbols-regex "init_gi|PyInit__gi" _gi_la_LIBADD = \ $(GI_LIBS) @@ -352,6 +356,8 @@ _gi_la_SOURCES = \ pygi-invoke.h \ pygi-foreign.c \ pygi-foreign.h \ + pygi-foreign-gvariant.c \ + pygi-foreign-gvariant.h \ pygi-struct.c \ pygi-struct.h \ pygi-argument.c \ @@ -366,6 +372,8 @@ _gi_la_SOURCES = \ pygi-callbacks.h \ pygi.h \ pygi-private.h \ + pygi-property.c \ + pygi-property.h \ pygobject-external.h \ gimodule.c @@ -377,18 +385,18 @@ _gi_cairo_la_CFLAGS = \ _gi_cairo_la_LDFLAGS = \ -module \ -avoid-version \ - -export-symbols-regex init_gi_cairo + -export-symbols-regex "init_gi_cairo|PyInit__gi_cairo" _gi_cairo_la_LIBADD = \ $(GI_LIBS) \ $(PYCAIRO_LIBS) _gi_cairo_la_SOURCES = pygi-foreign-cairo.c -pygi_LTLIBRARIES = _gi.la _gi_cairo.la +pygi_LTLIBRARIES = _gi.la $(am__append_1) all: all-recursive .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .la .lo .o .obj .so $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -453,7 +461,7 @@ clean-pygiLTLIBRARIES: _gi.la: $(_gi_la_OBJECTS) $(_gi_la_DEPENDENCIES) $(AM_V_CCLD)$(_gi_la_LINK) -rpath $(pygidir) $(_gi_la_OBJECTS) $(_gi_la_LIBADD) $(LIBS) _gi_cairo.la: $(_gi_cairo_la_OBJECTS) $(_gi_cairo_la_DEPENDENCIES) - $(AM_V_CCLD)$(_gi_cairo_la_LINK) -rpath $(pygidir) $(_gi_cairo_la_OBJECTS) $(_gi_cairo_la_LIBADD) $(LIBS) + $(AM_V_CCLD)$(_gi_cairo_la_LINK) $(am__gi_cairo_la_rpath) $(_gi_cairo_la_OBJECTS) $(_gi_cairo_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -467,9 +475,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-boxed.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-callbacks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-closure.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-foreign-gvariant.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-foreign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-info.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-invoke.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-property.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-repository.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-struct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/_gi_la-pygi-type.Plo@am__quote@ @@ -530,6 +540,14 @@ _gi_la-pygi-foreign.lo: pygi-foreign.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-foreign.lo `test -f 'pygi-foreign.c' || echo '$(srcdir)/'`pygi-foreign.c +_gi_la-pygi-foreign-gvariant.lo: pygi-foreign-gvariant.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-pygi-foreign-gvariant.lo -MD -MP -MF $(DEPDIR)/_gi_la-pygi-foreign-gvariant.Tpo -c -o _gi_la-pygi-foreign-gvariant.lo `test -f 'pygi-foreign-gvariant.c' || echo '$(srcdir)/'`pygi-foreign-gvariant.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-pygi-foreign-gvariant.Tpo $(DEPDIR)/_gi_la-pygi-foreign-gvariant.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pygi-foreign-gvariant.c' object='_gi_la-pygi-foreign-gvariant.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-foreign-gvariant.lo `test -f 'pygi-foreign-gvariant.c' || echo '$(srcdir)/'`pygi-foreign-gvariant.c + _gi_la-pygi-struct.lo: pygi-struct.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-pygi-struct.lo -MD -MP -MF $(DEPDIR)/_gi_la-pygi-struct.Tpo -c -o _gi_la-pygi-struct.lo `test -f 'pygi-struct.c' || echo '$(srcdir)/'`pygi-struct.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-pygi-struct.Tpo $(DEPDIR)/_gi_la-pygi-struct.Plo @@ -578,6 +596,14 @@ _gi_la-pygi-callbacks.lo: pygi-callbacks.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-callbacks.lo `test -f 'pygi-callbacks.c' || echo '$(srcdir)/'`pygi-callbacks.c +_gi_la-pygi-property.lo: pygi-property.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-pygi-property.lo -MD -MP -MF $(DEPDIR)/_gi_la-pygi-property.Tpo -c -o _gi_la-pygi-property.lo `test -f 'pygi-property.c' || echo '$(srcdir)/'`pygi-property.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-pygi-property.Tpo $(DEPDIR)/_gi_la-pygi-property.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pygi-property.c' object='_gi_la-pygi-property.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -c -o _gi_la-pygi-property.lo `test -f 'pygi-property.c' || echo '$(srcdir)/'`pygi-property.c + _gi_la-gimodule.lo: gimodule.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(_gi_la_CFLAGS) $(CFLAGS) -MT _gi_la-gimodule.lo -MD -MP -MF $(DEPDIR)/_gi_la-gimodule.Tpo -c -o _gi_la-gimodule.lo `test -f 'gimodule.c' || echo '$(srcdir)/'`gimodule.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/_gi_la-gimodule.Tpo $(DEPDIR)/_gi_la-gimodule.Plo @@ -960,15 +986,13 @@ uninstall-am: uninstall-pygiLTLIBRARIES uninstall-pygiPYTHON # This is to ensure we have a symlink to the .so in the # build directory, which the Python interpreter can load # directly without having to know how to parse .la files. -_gi.so: _gi.la - rm -f $@ && $(LN_S) .libs/$@ $@ -_gi_cairo.so: _gi_cairo.la - rm -f $@ && $(LN_S) .libs/$@ $@ +.la.so: + test -L $@ || $(LN_S) .libs/$@ $@ -all-local: _gi.so _gi_cairo.so -check-local: _gi.so _gi_cairo.so +all-local: $(LTLIBRARIES:.la=.so) +check-local: $(LTLIBRARIES:.la=.so) clean-local: - rm -f _gi.so _gi_cairo.so + rm -f $(LTLIBRARIES:.la=.so) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/gi/gimodule.c b/gi/gimodule.c index df0db7a..89caf4e 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -25,6 +25,7 @@ #include "pygi.h" #include +#include static PyObject * _wrap_pyg_enum_add (PyObject *self, @@ -195,12 +196,17 @@ _wrap_pyg_hook_up_vfunc_implementation (PyObject *self, PyObject *args) field_info = g_struct_info_get_field (struct_info, i); if (strcmp (g_base_info_get_name ( (GIBaseInfo*) field_info), - g_base_info_get_name ( (GIBaseInfo*) vfunc_info)) != 0) + g_base_info_get_name ( (GIBaseInfo*) vfunc_info)) != 0) { + g_base_info_unref (field_info); continue; + } type_info = g_field_info_get_type (field_info); - if (g_type_info_get_tag (type_info) != GI_TYPE_TAG_INTERFACE) + if (g_type_info_get_tag (type_info) != GI_TYPE_TAG_INTERFACE) { + g_base_info_unref (type_info); + g_base_info_unref (field_info); continue; + } interface_info = g_type_info_get_interface (type_info); g_assert (g_base_info_get_type (interface_info) == GI_INFO_TYPE_CALLBACK); @@ -229,32 +235,85 @@ _wrap_pyg_hook_up_vfunc_implementation (PyObject *self, PyObject *args) Py_RETURN_NONE; } -static PyMethodDef _pygi_functions[] = { +static PyObject * +_wrap_pyg_variant_new_tuple (PyObject *self, PyObject *args) +{ + PyObject *py_values; + GVariant **values = NULL; + GVariant *variant = NULL; + PyObject *py_variant = NULL; + PyObject *py_type; + gssize i; + + if (!PyArg_ParseTuple (args, "O!:variant_new_tuple", + &PyTuple_Type, &py_values)) { + return NULL; + } + + py_type = _pygi_type_import_by_name ("GLib", "Variant"); + + values = g_newa (GVariant*, PyTuple_Size (py_values)); + + for (i = 0; i < PyTuple_Size (py_values); i++) { + PyObject *value = PyTuple_GET_ITEM (py_values, i); + + if (!PyObject_IsInstance (value, py_type)) { + PyErr_Format (PyExc_TypeError, "argument %d is not a GLib.Variant", i); + return NULL; + } + + values[i] = (GVariant *) ( (PyGPointer *) value)->pointer; + } + + variant = g_variant_new_tuple (values, PyTuple_Size (py_values)); + + py_variant = _pygi_struct_new ( (PyTypeObject *) py_type, variant, FALSE); + + return py_variant; +} + +static PyObject * +_wrap_pyg_variant_type_from_string (PyObject *self, PyObject *args) +{ + char *type_string; + PyObject *py_type; + PyObject *py_variant = NULL; + + if (!PyArg_ParseTuple (args, "s:variant_type_from_string", + &type_string)) { + return NULL; + } + + py_type = _pygi_type_import_by_name ("GLib", "VariantType"); + + py_variant = _pygi_struct_new ( (PyTypeObject *) py_type, type_string, FALSE); + + return py_variant; +} + +static PyMethodDef _gi_functions[] = { { "enum_add", (PyCFunction) _wrap_pyg_enum_add, METH_VARARGS | METH_KEYWORDS }, { "flags_add", (PyCFunction) _wrap_pyg_flags_add, METH_VARARGS | METH_KEYWORDS }, { "set_object_has_new_constructor", (PyCFunction) _wrap_pyg_set_object_has_new_constructor, METH_VARARGS | METH_KEYWORDS }, { "register_interface_info", (PyCFunction) _wrap_pyg_register_interface_info, METH_VARARGS }, { "hook_up_vfunc_implementation", (PyCFunction) _wrap_pyg_hook_up_vfunc_implementation, METH_VARARGS }, + { "variant_new_tuple", (PyCFunction) _wrap_pyg_variant_new_tuple, METH_VARARGS }, + { "variant_type_from_string", (PyCFunction) _wrap_pyg_variant_type_from_string, METH_VARARGS }, { NULL, NULL, 0 } }; static struct PyGI_API CAPI = { pygi_type_import_by_g_type_real, + pygi_get_property_value_real, + pygi_set_property_value_real, pygi_register_foreign_struct_real, }; -PyMODINIT_FUNC -init_gi (void) +PYGLIB_MODULE_START(_gi, "_gi") { - PyObject *m; PyObject *api; - m = Py_InitModule ("_gi", _pygi_functions); - if (m == NULL) { - return; - } - if (pygobject_init (-1, -1, -1) == NULL) { return; } @@ -263,16 +322,16 @@ init_gi (void) return; } - _pygi_repository_register_types (m); - _pygi_info_register_types (m); - _pygi_struct_register_types (m); - _pygi_boxed_register_types (m); + _pygi_repository_register_types (module); + _pygi_info_register_types (module); + _pygi_struct_register_types (module); + _pygi_boxed_register_types (module); _pygi_argument_init(); api = PyCObject_FromVoidPtr ( (void *) &CAPI, NULL); if (api == NULL) { return; } - PyModule_AddObject (m, "_API", api); + PyModule_AddObject (module, "_API", api); } - +PYGLIB_MODULE_END diff --git a/gi/importer.py b/gi/importer.py index 6076692..1cb9b92 100644 --- a/gi/importer.py +++ b/gi/importer.py @@ -27,7 +27,7 @@ import sys import gobject from ._gi import Repository, RepositoryError -from .module import DynamicModule, DynamicGObjectModule, ModuleProxy +from .module import DynamicModule, DynamicGObjectModule repository = Repository.get_default() @@ -48,10 +48,10 @@ class DynamicImporter(object): path, namespace = fullname.rsplit('.', 1) if path != self.path: return - try: - repository.require(namespace) - except RepositoryError, e: - logging.exception(e) + + if not repository.enumerate_versions(namespace): + logging.error('Could not find any typelib for %s', namespace) + return None else: return self @@ -69,18 +69,10 @@ class DynamicImporter(object): dynamic_module = DynamicModule(namespace) modules[namespace] = dynamic_module - overrides_modules = __import__('gi.overrides', fromlist=[namespace]) - overrides_module = getattr(overrides_modules, namespace, None) - - if overrides_module is not None: - module = ModuleProxy(fullname, namespace, dynamic_module, overrides_module) - else: - module = dynamic_module - - module.__file__ = '<%s>' % fullname - module.__loader__ = self + dynamic_module.__file__ = '<%s>' % fullname + dynamic_module.__loader__ = self - sys.modules[fullname] = module + sys.modules[fullname] = dynamic_module - return module + return dynamic_module diff --git a/gi/module.py b/gi/module.py index e149986..819fcc6 100644 --- a/gi/module.py +++ b/gi/module.py @@ -64,6 +64,7 @@ def get_parent_for_object(object_info): module = __import__('gi.repository.%s' % namespace, fromlist=[name]) return getattr(module, name) + def get_interfaces_for_object(object_info): interfaces = [] for interface_info in object_info.get_interfaces(): @@ -75,17 +76,24 @@ def get_interfaces_for_object(object_info): return interfaces -class DynamicModule(object): +class IntrospectionModule(object): - def __init__(self, namespace): + def __init__(self, namespace, version=None): + repository.require(namespace, version) self._namespace = namespace + self.version = version self.__name__ = 'gi.repository.' + namespace + repository.require(self._namespace, self.version) + + if self.version is None: + self.version = repository.get_version(self._namespace) + def __getattr__(self, name): info = repository.find_by_name(self._namespace, name) if not info: raise AttributeError("%r object has no attribute %r" % ( - self.__class__.__name__, name)) + self.__name__, name)) if isinstance(info, EnumInfo): g_type = info.get_g_type() @@ -133,7 +141,7 @@ class DynamicModule(object): elif g_type.is_a(gobject.TYPE_POINTER) or g_type == gobject.TYPE_NONE: bases = (Struct,) else: - raise TypeError, "unable to create a wrapper for %s.%s" % (info.get_namespace(), info.get_name()) + raise TypeError("unable to create a wrapper for %s.%s" % (info.get_namespace(), info.get_name())) metaclass = StructMeta else: raise NotImplementedError(info) @@ -162,10 +170,10 @@ class DynamicModule(object): def __repr__(self): path = repository.get_typelib_path(self._namespace) - return "" % (self._namespace, path) + return "" % (self._namespace, path) -class DynamicGObjectModule(DynamicModule): +class DynamicGObjectModule(IntrospectionModule): """Wrapper for the GObject module This class allows us to access both the static PyGObject module and the GI GObject module @@ -182,12 +190,11 @@ class DynamicGObjectModule(DynamicModule): """ def __init__(self): - self._namespace = 'GObject' - self._module = gobject + IntrospectionModule.__init__(self, namespace='GObject') def __getattr__(self, name): # first see if this attr is in the gobject module - attr = getattr(self._module, name, None) + attr = getattr(gobject, name, None) # if not in module assume request for an attr exported through GI if attr is None: @@ -195,23 +202,34 @@ class DynamicGObjectModule(DynamicModule): return attr -class ModuleProxy(object): - - def __init__(self, name, namespace, dynamic_module, overrides_module): - self.__name__ = name +class DynamicModule(object): + def __init__(self, namespace): self._namespace = namespace - self._dynamic_module = dynamic_module - self._overrides_module = overrides_module + self.introspection_module = None + self._version = None + self._overrides_module = None + + def require_version(self, version): + if self.introspection_module is not None and \ + self.introspection_module.version != version: + raise RuntimeError('Module has been already loaded ') + self._version = version + + def _import(self): + self.introspection_module = IntrospectionModule(self._namespace, + self._version) + + overrides_modules = __import__('gi.overrides', fromlist=[self._namespace]) + self._overrides_module = getattr(overrides_modules, self._namespace, None) def __getattr__(self, name): - override_exports = getattr(self._overrides_module, '__all__', ()) - if (name in override_exports): - attribute = getattr(self._overrides_module, name, None) - else: - attribute = getattr(self._dynamic_module, name) - return attribute + if self.introspection_module is None: + self._import() - def __str__(self): - return "" % self.__name__ + if self._overrides_module is not None: + override_exports = getattr(self._overrides_module, '__all__', ()) + if name in override_exports: + return getattr(self._overrides_module, name, None) + return getattr(self.introspection_module, name) diff --git a/gi/overrides/GIMarshallingTests.py b/gi/overrides/GIMarshallingTests.py index 768efd7..ee01495 100644 --- a/gi/overrides/GIMarshallingTests.py +++ b/gi/overrides/GIMarshallingTests.py @@ -21,7 +21,7 @@ from ..types import override from ..importer import modules -GIMarshallingTests = modules['GIMarshallingTests'] +GIMarshallingTests = modules['GIMarshallingTests'].introspection_module __all__ = [] diff --git a/gi/overrides/GLib.py b/gi/overrides/GLib.py new file mode 100644 index 0000000..78d8c35 --- /dev/null +++ b/gi/overrides/GLib.py @@ -0,0 +1,165 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- +# vim: tabstop=4 shiftwidth=4 expandtab +# +# Copyright (C) 2010 Tomeu Vizoso +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +# USA + +from ..importer import modules +from .._gi import variant_new_tuple, variant_type_from_string + +GLib = modules['GLib'].introspection_module + +__all__ = [] + +class _VariantCreator(object): + + _LEAF_CONSTRUCTORS = { + 'b': GLib.Variant.new_boolean, + 'y': GLib.Variant.new_byte, + 'n': GLib.Variant.new_int16, + 'q': GLib.Variant.new_uint16, + 'i': GLib.Variant.new_int32, + 'u': GLib.Variant.new_uint32, + 'x': GLib.Variant.new_int64, + 't': GLib.Variant.new_uint64, + 'h': GLib.Variant.new_handle, + 'd': GLib.Variant.new_double, + 's': GLib.Variant.new_string, + 'o': GLib.Variant.new_object_path, + 'g': GLib.Variant.new_signature, + 'v': GLib.Variant.new_variant, + } + + def __init__(self, format_string, args): + self._format_string = format_string + self._args = args + + def create(self): + if self._format_string_is_leaf(): + return self._new_variant_leaf() + + format_char = self._pop_format_char() + arg = self._pop_arg() + + if format_char == 'm': + raise NotImplementedError() + else: + builder = GLib.VariantBuilder() + if format_char == '(': + builder.init(variant_type_from_string('r')) + elif format_char == '{': + builder.init(variant_type_from_string('{?*}')) + else: + raise NotImplementedError() + format_char = self._pop_format_char() + while format_char not in [')', '}']: + builder.add_value(Variant(format_char, arg)) + format_char = self._pop_format_char() + if self._args: + arg = self._pop_arg() + return builder.end() + + def _format_string_is_leaf(self): + format_char = self._format_string[0] + return not format_char in ['m', '(', '{'] + + def _format_string_is_nnp(self): + format_char = self._format_string[0] + return format_char in ['a', 's', 'o', 'g', '^', '@', '*', '?', 'r', + 'v', '&'] + + def _new_variant_leaf(self): + if self._format_string_is_nnp(): + return self._new_variant_nnp() + + format_char = self._pop_format_char() + arg = self._pop_arg() + + return _VariantCreator._LEAF_CONSTRUCTORS[format_char](arg) + + def _new_variant_nnp(self): + format_char = self._pop_format_char() + arg = self._pop_arg() + + if format_char == '&': + format_char = self._pop_format_char() + + if format_char == 'a': + builder = GLib.VariantBuilder() + builder.init(variant_type_from_string('a*')) + + element_format_string = self._pop_leaf_format_string() + + if isinstance(arg, dict): + for element in arg.items(): + value = Variant(element_format_string, *element) + builder.add_value(value) + else: + for element in arg: + value = Variant(element_format_string, element) + builder.add_value(value) + return builder.end() + elif format_char == '^': + raise NotImplementedError() + elif format_char == '@': + raise NotImplementedError() + elif format_char == '*': + raise NotImplementedError() + elif format_char == 'r': + raise NotImplementedError() + elif format_char == '?': + raise NotImplementedError() + else: + return _VariantCreator._LEAF_CONSTRUCTORS[format_char](arg) + + def _pop_format_char(self): + format_char = self._format_string[0] + self._format_string = self._format_string[1:] + return format_char + + def _pop_leaf_format_string(self): + # FIXME: This will break when the leaf is inside a tuple or dict entry + format_string = self._format_string + self._format_string = '' + return format_string + + def _pop_arg(self): + arg = self._args[0] + self._args = self._args[1:] + return arg + +class Variant(GLib.Variant): + def __new__(cls, format_string, *args): + creator = _VariantCreator(format_string, args) + return creator.create() + + def __repr__(self): + return '' % getattr(self, 'print')(True) + +@classmethod +def new_tuple(cls, *elements): + return variant_new_tuple(elements) + +def get_string(self): + value, length = GLib.Variant.get_string(self) + return value + +setattr(Variant, 'new_tuple', new_tuple) +setattr(Variant, 'get_string', get_string) + +__all__.append('Variant') + diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py index 4eaff08..23a9d8e 100644 --- a/gi/overrides/Gdk.py +++ b/gi/overrides/Gdk.py @@ -22,7 +22,7 @@ from ..types import override from ..importer import modules -Gdk = modules['Gdk'] +Gdk = modules['Gdk'].introspection_module __all__ = [] @@ -43,6 +43,25 @@ class Color(Gdk.Color): Color = override(Color) __all__.append('Color') +if Gdk.version == '2.0': + class Rectangle(Gdk.Rectangle): + + def __init__(self, x, y, width, height): + Gdk.Rectangle.__init__(self) + self.x = x + self.y = y + self.width = width + self.height = height + + def __new__(cls, *args, **kwargs): + return Gdk.Rectangle.__new__(cls) + + def __repr__(self): + return '' % (self.x, self.y, self.height, self.width) + + Rectangle = override(Rectangle) + __all__.append('Rectangle') + class Drawable(Gdk.Drawable): def cairo_create(self): return Gdk.cairo_create(self) @@ -50,6 +69,54 @@ class Drawable(Gdk.Drawable): Drawable = override(Drawable) __all__.append('Drawable') +class Event(Gdk.Event): + _UNION_MEMBERS = { + Gdk.EventType.DELETE: 'any', + Gdk.EventType.DESTROY: 'any', + Gdk.EventType.EXPOSE: 'expose', + Gdk.EventType.MOTION_NOTIFY: 'motion', + Gdk.EventType.BUTTON_PRESS: 'button', + #Gdk.EventType.2BUTTON_PRESS: 'button', + #Gdk.EventType.3BUTTON_PRESS: 'button', + Gdk.EventType.BUTTON_RELEASE: 'button', + Gdk.EventType.KEY_PRESS: 'key', + Gdk.EventType.KEY_RELEASE: 'key', + Gdk.EventType.ENTER_NOTIFY: 'crossing', + Gdk.EventType.LEAVE_NOTIFY: 'crossing', + Gdk.EventType.FOCUS_CHANGE: 'focus_change', + Gdk.EventType.CONFIGURE: 'configure', + Gdk.EventType.MAP: 'any', + Gdk.EventType.UNMAP: 'any', + Gdk.EventType.PROPERTY_NOTIFY: 'property', + Gdk.EventType.SELECTION_CLEAR: 'selection', + Gdk.EventType.SELECTION_REQUEST: 'selection', + Gdk.EventType.SELECTION_NOTIFY: 'selection', + Gdk.EventType.PROXIMITY_IN: 'proximity', + Gdk.EventType.PROXIMITY_OUT: 'proximity', + Gdk.EventType.DRAG_ENTER: 'dnd', + Gdk.EventType.DRAG_LEAVE: 'dnd', + Gdk.EventType.DRAG_MOTION: 'dnd', + Gdk.EventType.DRAG_STATUS: 'dnd', + Gdk.EventType.DROP_START: 'dnd', + Gdk.EventType.DROP_FINISHED: 'dnd', + Gdk.EventType.CLIENT_EVENT: 'client', + Gdk.EventType.VISIBILITY_NOTIFY: 'visibility', + Gdk.EventType.NO_EXPOSE: 'no_expose' + } + + def __new__(cls, *args, **kwargs): + return Gdk.Event.__new__(cls) + + def __getattr__(self, name): + real_event = getattr(self, '_UNION_MEMBERS').get(self.type) + if real_event: + return getattr(getattr(self, real_event), name) + else: + return getattr(self, name) + +Event = override(Event) +__all__.append('Event') + import sys diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 38a90b3..1f6901c 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -19,13 +19,21 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA +import sys import gobject from gi.repository import Gdk from gi.repository import GObject from ..types import override from ..importer import modules -Gtk = modules['Gtk'] +if sys.version_info >= (3, 0): + _basestring = str + _callable = lambda c: hasattr(c, '__call__') +else: + _basestring = basestring + _callable = callable + +Gtk = modules['Gtk'].introspection_module __all__ = [] class ActionGroup(Gtk.ActionGroup): @@ -184,7 +192,7 @@ __all__.append('ActionGroup') class UIManager(Gtk.UIManager): def add_ui_from_string(self, buffer): - if not isinstance(buffer, basestring): + if not isinstance(buffer, _basestring): raise TypeError('buffer must be a string') length = len(buffer) @@ -207,7 +215,7 @@ class Builder(Gtk.Builder): if handler is None: raise AttributeError('Handler %s not found' % handler_name) - if not callable(handler): + if not _callable(handler): raise TypeError('Handler %s is not a method or function' % handler_name) after = flags or GObject.ConnectFlags.AFTER @@ -226,7 +234,7 @@ class Builder(Gtk.Builder): obj_or_map); def add_from_string(self, buffer): - if not isinstance(buffer, basestring): + if not isinstance(buffer, _basestring): raise TypeError('buffer must be a string') length = len(buffer) @@ -234,7 +242,7 @@ class Builder(Gtk.Builder): return Gtk.Builder.add_from_string(self, buffer, length) def add_objects_from_string(self, buffer, object_ids): - if not isinstance(buffer, basestring): + if not isinstance(buffer, _basestring): raise TypeError('buffer must be a string') length = len(buffer) @@ -256,8 +264,14 @@ class Dialog(Gtk.Dialog): self.set_modal(True) if flags & Gtk.DialogFlags.DESTROY_WITH_PARENT: self.set_destroy_with_parent(True) - if flags & Gtk.DialogFlags.NO_SEPARATOR: - self.set_has_separator(False) + + # NO_SEPARATOR has been removed from Gtk 3 + try: + if flags & Gtk.DialogFlags.NO_SEPARATOR: + self.set_has_separator(False) + except AttributeError: + pass + if buttons: self.add_buttons(*buttons) @@ -324,14 +338,14 @@ class TextBuffer(Gtk.TextBuffer): return tag def insert(self, iter, text): - if not isinstance(text , basestring): + if not isinstance(text , _basestring): raise TypeError('text must be a string, not %s' % type(text)) length = len(text) Gtk.TextBuffer.insert(self, iter, text, length) def insert_at_cursor(self, text): - if not isinstance(text , basestring): + if not isinstance(text , _basestring): raise TypeError('text must be a string, not %s' % type(text)) length = len(text) @@ -382,7 +396,7 @@ class TreeStore(Gtk.TreeStore, TreeModel): if len(row) != n_columns: raise ValueError('row sequence has the incorrect number of elements') - for i in xrange(n_columns): + for i in range(n_columns): if row[i] is not None: self.set_value(treeiter, i, row[i]) @@ -399,12 +413,25 @@ class TreeViewColumn(Gtk.TreeViewColumn): if cell_renderer: self.pack_start(cell_renderer, True) - for (name, value) in attributes.iteritems(): + for (name, value) in attributes.items(): self.add_attribute(cell_renderer, name, value) TreeViewColumn = override(TreeViewColumn) __all__.append('TreeViewColumn') +class Button(Gtk.Button): + def __init__(self, label=None, stock=None, use_underline=False): + if stock: + label = stock + use_stock = True + use_underline = True + else: + use_stock = False + Gtk.Button.__init__(self, label=label, use_stock=use_stock, + use_underline=use_underline) +Button = override(Button) +__all__.append('Button') + import sys initialized, argv = Gtk.init_check(sys.argv) diff --git a/gi/overrides/Makefile.am b/gi/overrides/Makefile.am index 62f6457..b36c7a5 100644 --- a/gi/overrides/Makefile.am +++ b/gi/overrides/Makefile.am @@ -4,6 +4,7 @@ pkgpyexecdir = $(pyexecdir)/gtk-2.0/gi pygioverridesdir = $(pkgpyexecdir)/overrides pygioverrides_PYTHON = \ + GLib.py \ Gtk.py \ Gdk.py \ GIMarshallingTests.py \ diff --git a/gi/overrides/Makefile.in b/gi/overrides/Makefile.in index b0a8c01..630735c 100644 --- a/gi/overrides/Makefile.in +++ b/gi/overrides/Makefile.in @@ -115,6 +115,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ @@ -237,6 +238,7 @@ top_srcdir = @top_srcdir@ PLATFORM_VERSION = 2.0 pygioverridesdir = $(pkgpyexecdir)/overrides pygioverrides_PYTHON = \ + GLib.py \ Gtk.py \ Gdk.py \ GIMarshallingTests.py \ diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 9ace5d2..e3dd8c3 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -3,7 +3,7 @@ * * Copyright (C) 2005-2009 Johan Dahlin * - * pygi-argument.c: GArgument - PyObject conversion functions. + * pygi-argument.c: GIArgument - PyObject conversion functions. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -28,7 +28,7 @@ #include #include - +#include static void _pygi_g_type_tag_py_bounds (GITypeTag type_tag, @@ -37,29 +37,29 @@ _pygi_g_type_tag_py_bounds (GITypeTag type_tag, { switch (type_tag) { case GI_TYPE_TAG_INT8: - *lower = PyInt_FromLong (-128); - *upper = PyInt_FromLong (127); + *lower = PYGLIB_PyLong_FromLong (-128); + *upper = PYGLIB_PyLong_FromLong (127); break; case GI_TYPE_TAG_UINT8: - *upper = PyInt_FromLong (255); - *lower = PyInt_FromLong (0); + *upper = PYGLIB_PyLong_FromLong (255); + *lower = PYGLIB_PyLong_FromLong (0); break; case GI_TYPE_TAG_INT16: - *lower = PyInt_FromLong (-32768); - *upper = PyInt_FromLong (32767); + *lower = PYGLIB_PyLong_FromLong (-32768); + *upper = PYGLIB_PyLong_FromLong (32767); break; case GI_TYPE_TAG_UINT16: - *upper = PyInt_FromLong (65535); - *lower = PyInt_FromLong (0); + *upper = PYGLIB_PyLong_FromLong (65535); + *lower = PYGLIB_PyLong_FromLong (0); break; case GI_TYPE_TAG_INT32: - *lower = PyInt_FromLong (G_MININT32); - *upper = PyInt_FromLong (G_MAXINT32); + *lower = PYGLIB_PyLong_FromLong (G_MININT32); + *upper = PYGLIB_PyLong_FromLong (G_MAXINT32); break; case GI_TYPE_TAG_UINT32: /* Note: On 32-bit archs, this number doesn't fit in a long. */ *upper = PyLong_FromLongLong (G_MAXUINT32); - *lower = PyInt_FromLong (0); + *lower = PYGLIB_PyLong_FromLong (0); break; case GI_TYPE_TAG_INT64: /* Note: On 32-bit archs, these numbers don't fit in a long. */ @@ -68,7 +68,7 @@ _pygi_g_type_tag_py_bounds (GITypeTag type_tag, break; case GI_TYPE_TAG_UINT64: *upper = PyLong_FromUnsignedLongLong (G_MAXUINT64); - *lower = PyInt_FromLong (0); + *lower = PYGLIB_PyLong_FromLong (0); break; case GI_TYPE_TAG_FLOAT: *upper = PyFloat_FromDouble (G_MAXFLOAT); @@ -160,6 +160,101 @@ _pygi_g_registered_type_info_check_object (GIRegisteredTypeInfo *info, return retval; } +gint +_pygi_g_type_interface_check_object (GIBaseInfo *info, + PyObject *object) +{ + gint retval = 1; + GIInfoType info_type; + + info_type = g_base_info_get_type (info); + switch (info_type) { + case GI_INFO_TYPE_CALLBACK: + if (!PyCallable_Check (object)) { + PyErr_Format (PyExc_TypeError, "Must be callable, not %s", + object->ob_type->tp_name); + retval = 0; + } + break; + case GI_INFO_TYPE_ENUM: + retval = 0; + if (PyNumber_Check (object)) { + PyObject *number = PYGLIB_PyNumber_Long (object); + if (number == NULL) + PyErr_Clear(); + else { + glong value = PYGLIB_PyLong_AsLong (number); + int i; + for (i = 0; i < g_enum_info_get_n_values (info); i++) { + GIValueInfo *value_info = g_enum_info_get_value (info, i); + glong enum_value = g_value_info_get_value (value_info); + if (value == enum_value) { + retval = 1; + break; + } + } + } + } + if (retval < 1) + retval = _pygi_g_registered_type_info_check_object ( + (GIRegisteredTypeInfo *) info, TRUE, object); + break; + case GI_INFO_TYPE_FLAGS: + if (PyNumber_Check (object)) { + /* Accept 0 as a valid flag value */ + PyObject *number = PYGLIB_PyNumber_Long (object); + if (number == NULL) + PyErr_Clear(); + else { + long value = PYGLIB_PyLong_AsLong (number); + if (value == 0) + break; + else if (value == -1) + PyErr_Clear(); + } + } + retval = _pygi_g_registered_type_info_check_object ( + (GIRegisteredTypeInfo *) info, TRUE, object); + break; + case GI_INFO_TYPE_STRUCT: + { + GType type; + + /* Handle special cases. */ + type = g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info); + if (g_type_is_a (type, G_TYPE_VALUE)) { + GType object_type; + object_type = pyg_type_from_object ( (PyObject *) object->ob_type); + if (object_type == G_TYPE_INVALID) { + PyErr_Format (PyExc_TypeError, "Must be of a known GType, not %s", + object->ob_type->tp_name); + retval = 0; + } + break; + } else if (g_type_is_a (type, G_TYPE_CLOSURE)) { + if (!PyCallable_Check (object)) { + PyErr_Format (PyExc_TypeError, "Must be callable, not %s", + object->ob_type->tp_name); + retval = 0; + } + break; + } + + /* Fallback. */ + } + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_OBJECT: + case GI_INFO_TYPE_UNION: + retval = _pygi_g_registered_type_info_check_object ( (GIRegisteredTypeInfo *) info, TRUE, object); + break; + default: + g_assert_not_reached(); + } + + return retval; +} + gint _pygi_g_type_info_check_object (GITypeInfo *type_info, PyObject *object, @@ -204,7 +299,7 @@ _pygi_g_type_info_check_object (GITypeInfo *type_info, if (type_tag == GI_TYPE_TAG_FLOAT || type_tag == GI_TYPE_TAG_DOUBLE) { number = PyNumber_Float (object); } else { - number = PyNumber_Int (object); + number = PYGLIB_PyNumber_Long (object); } _pygi_g_type_tag_py_bounds (type_tag, &lower, &upper); @@ -215,8 +310,8 @@ _pygi_g_type_info_check_object (GITypeInfo *type_info, } /* Check bounds */ - if (PyObject_Compare (lower, number) > 0 - || PyObject_Compare (upper, number) < 0) { + if (PyObject_RichCompareBool (lower, number, Py_GT) + || PyObject_RichCompareBool (upper, number, Py_LT)) { PyObject *lower_str; PyObject *upper_str; @@ -232,10 +327,30 @@ _pygi_g_type_info_check_object (GITypeInfo *type_info, goto check_number_error_release; } +#if PY_VERSION_HEX < 0x03000000 PyErr_Format (PyExc_ValueError, "Must range from %s to %s", PyString_AS_STRING (lower_str), PyString_AS_STRING (upper_str)); +#else + { + PyObject *lower_pybytes_obj = PyUnicode_AsUTF8String (lower_str); + if (!lower_pybytes_obj) + goto utf8_fail; + + PyObject *upper_pybytes_obj = PyUnicode_AsUTF8String (upper_str); + if (!upper_pybytes_obj) { + Py_DECREF(lower_pybytes_obj); + goto utf8_fail; + } + PyErr_Format (PyExc_ValueError, "Must range from %s to %s", + PyBytes_AsString (lower_pybytes_obj), + PyBytes_AsString (upper_pybytes_obj)); + Py_DECREF (lower_pybytes_obj); + Py_DECREF (upper_pybytes_obj); + } +utf8_fail: +#endif retval = 0; check_number_error_release: @@ -251,15 +366,7 @@ check_number_release: } case GI_TYPE_TAG_GTYPE: { - gint is_instance; - - is_instance = PyObject_IsInstance (object, (PyObject *) &PyGTypeWrapper_Type); - if (is_instance < 0) { - retval = -1; - break; - } - - if (!is_instance && (!PyType_Check (object) || pyg_type_from_object (object) == 0)) { + if (pyg_type_from_object (object) == 0) { PyErr_Format (PyExc_TypeError, "Must be gobject.GType, not %s", object->ob_type->tp_name); retval = 0; @@ -268,7 +375,7 @@ check_number_release: } case GI_TYPE_TAG_UTF8: case GI_TYPE_TAG_FILENAME: - if (!PyString_Check (object)) { + if (!PYGLIB_PyUnicode_Check (object)) { PyErr_Format (PyExc_TypeError, "Must be string, not %s", object->ob_type->tp_name); retval = 0; @@ -334,77 +441,11 @@ check_number_release: case GI_TYPE_TAG_INTERFACE: { GIBaseInfo *info; - GIInfoType info_type; info = g_type_info_get_interface (type_info); g_assert (info != NULL); - info_type = g_base_info_get_type (info); - - switch (info_type) { - case GI_INFO_TYPE_CALLBACK: - if (!PyCallable_Check (object)) { - PyErr_Format (PyExc_TypeError, "Must be callable, not %s", - object->ob_type->tp_name); - retval = 0; - } - break; - case GI_INFO_TYPE_ENUM: - retval = _pygi_g_registered_type_info_check_object ( - (GIRegisteredTypeInfo *) info, TRUE, object); - break; - case GI_INFO_TYPE_FLAGS: - if (PyNumber_Check (object)) { - /* Accept 0 as a valid flag value */ - PyObject *number = PyNumber_Int (object); - if (number == NULL) - PyErr_Clear(); - else { - long value = PyInt_AsLong (number); - if (value == 0) - break; - else if (value == -1) - PyErr_Clear(); - } - } - retval = _pygi_g_registered_type_info_check_object ( - (GIRegisteredTypeInfo *) info, TRUE, object); - break; - case GI_INFO_TYPE_STRUCT: - { - GType type; - - /* Handle special cases. */ - type = g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info); - if (g_type_is_a (type, G_TYPE_VALUE)) { - GType object_type; - object_type = pyg_type_from_object ( (PyObject *) object->ob_type); - if (object_type == G_TYPE_INVALID) { - PyErr_Format (PyExc_TypeError, "Must be of a known GType, not %s", - object->ob_type->tp_name); - retval = 0; - } - break; - } else if (g_type_is_a (type, G_TYPE_CLOSURE)) { - if (!PyCallable_Check (object)) { - PyErr_Format (PyExc_TypeError, "Must be callable, not %s", - object->ob_type->tp_name); - retval = 0; - } - break; - } - - /* Fallback. */ - } - case GI_INFO_TYPE_BOXED: - case GI_INFO_TYPE_INTERFACE: - case GI_INFO_TYPE_OBJECT: - case GI_INFO_TYPE_UNION: - retval = _pygi_g_registered_type_info_check_object ( (GIRegisteredTypeInfo *) info, TRUE, object); - break; - default: - g_assert_not_reached(); - } + retval = _pygi_g_type_interface_check_object(info, object); g_base_info_unref (info); break; @@ -466,7 +507,8 @@ check_number_release: GITypeInfo *value_type_info; Py_ssize_t i; - if (!PyMapping_Check (object)) { + keys = PyMapping_Keys (object); + if (keys == NULL) { PyErr_Format (PyExc_TypeError, "Must be mapping, not %s", object->ob_type->tp_name); retval = 0; @@ -475,12 +517,7 @@ check_number_release: length = PyMapping_Length (object); if (length < 0) { - retval = -1; - break; - } - - keys = PyMapping_Keys (object); - if (keys == NULL) { + Py_DECREF (keys); retval = -1; break; } @@ -540,8 +577,8 @@ check_number_release: } GArray * -_pygi_argument_to_array (GArgument *arg, - GArgument *args[], +_pygi_argument_to_array (GIArgument *arg, + GIArgument *args[], GITypeInfo *type_info, gboolean is_method) { @@ -572,12 +609,6 @@ _pygi_argument_to_array (GArgument *arg, length_arg_pos = g_type_info_get_array_length (type_info); g_assert (length_arg_pos >= 0); - if (is_method) { - length_arg_pos--; - } - - g_assert (length_arg_pos >= 0); - /* FIXME: Take into account the type of the argument. */ length = args[length_arg_pos]->v_int; } @@ -593,15 +624,15 @@ _pygi_argument_to_array (GArgument *arg, return g_array; } -GArgument +GIArgument _pygi_argument_from_object (PyObject *object, GITypeInfo *type_info, GITransfer transfer) { - GArgument arg; + GIArgument arg; GITypeTag type_tag; - memset(&arg, 0, sizeof(GArgument)); + memset(&arg, 0, sizeof(GIArgument)); type_tag = g_type_info_get_tag (type_info); switch (type_tag) { @@ -622,12 +653,12 @@ _pygi_argument_from_object (PyObject *object, { PyObject *int_; - int_ = PyNumber_Int (object); + int_ = PYGLIB_PyNumber_Long (object); if (int_ == NULL) { break; } - arg.v_long = PyInt_AsLong (int_); + arg.v_long = PYGLIB_PyLong_AsLong (int_); Py_DECREF (int_); @@ -639,16 +670,18 @@ _pygi_argument_from_object (PyObject *object, PyObject *number; guint64 value; - number = PyNumber_Int (object); + number = PYGLIB_PyNumber_Long (object); if (number == NULL) { break; } +#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check (number)) { value = PyInt_AS_LONG (number); - } else { + } else +#endif + if (PyLong_Check (number)) value = PyLong_AsUnsignedLongLong (number); - } arg.v_uint64 = value; @@ -661,16 +694,18 @@ _pygi_argument_from_object (PyObject *object, PyObject *number; gint64 value; - number = PyNumber_Int (object); + number = PYGLIB_PyNumber_Long (object); if (number == NULL) { break; } +#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check (number)) { value = PyInt_AS_LONG (number); - } else { + } else +#endif + if (PyLong_Check (number)) value = PyLong_AsLongLong (number); - } arg.v_int64 = value; @@ -714,30 +749,53 @@ _pygi_argument_from_object (PyObject *object, } case GI_TYPE_TAG_UTF8: { - const gchar *string; + gchar *string; if (object == Py_None) { arg.v_string = NULL; break; } +#if PY_VERSION_HEX < 0x03000000 + string = g_strdup(PyString_AsString (object)); +#else + { + PyObject *pybytes_obj = PyUnicode_AsUTF8String (object); + if (!pybytes_obj) + break; - string = PyString_AsString (object); + string = g_strdup(PyBytes_AsString (pybytes_obj)); + Py_DECREF (pybytes_obj); + } +#endif + arg.v_string = string; - /* Don't need to check for errors, since g_strdup is NULL-proof. */ - arg.v_string = g_strdup (string); break; } case GI_TYPE_TAG_FILENAME: { GError *error = NULL; - const gchar *string; + gchar *string; + +#if PY_VERSION_HEX < 0x03000000 + string = g_strdup(PyString_AsString (object)); +#else + { + PyObject *pybytes_obj = PyUnicode_AsUTF8String (object); + if (!pybytes_obj) + break; + + string = g_strdup(PyBytes_AsString (pybytes_obj)); + Py_DECREF (pybytes_obj); + } +#endif - string = PyString_AsString (object); if (string == NULL) { break; } arg.v_string = g_filename_from_utf8 (string, -1, NULL, NULL, &error); + g_free(string); + if (arg.v_string == NULL) { PyErr_SetString (PyExc_Exception, error->message); /* TODO: Convert the error to an exception. */ @@ -781,7 +839,7 @@ _pygi_argument_from_object (PyObject *object, for (i = 0; i < length; i++) { PyObject *py_item; - GArgument item; + GIArgument item; py_item = PySequence_GetItem (object, i); if (py_item == NULL) { @@ -801,7 +859,7 @@ _pygi_argument_from_object (PyObject *object, array_item_error: /* Free everything we have converted so far. */ - _pygi_argument_release ( (GArgument *) &array, type_info, + _pygi_argument_release ( (GIArgument *) &array, type_info, GI_TRANSFER_NOTHING, GI_DIRECTION_IN); array = NULL; @@ -900,12 +958,12 @@ array_item_error: { PyObject *int_; - int_ = PyNumber_Int (object); + int_ = PYGLIB_PyNumber_Long (object); if (int_ == NULL) { break; } - arg.v_long = PyInt_AsLong (int_); + arg.v_long = PYGLIB_PyLong_AsLong (int_); Py_DECREF (int_); @@ -956,7 +1014,7 @@ array_item_error: for (i = length - 1; i >= 0; i--) { PyObject *py_item; - GArgument item; + GIArgument item; py_item = PySequence_GetItem (object, i); if (py_item == NULL) { @@ -981,7 +1039,7 @@ array_item_error: list_item_error: /* Free everything we have converted so far. */ - _pygi_argument_release ( (GArgument *) &list, type_info, + _pygi_argument_release ( (GIArgument *) &list, type_info, GI_TRANSFER_NOTHING, GI_DIRECTION_IN); list = NULL; @@ -1061,8 +1119,8 @@ list_item_error: for (i = 0; i < length; i++) { PyObject *py_key; PyObject *py_value; - GArgument key; - GArgument value; + GIArgument key; + GIArgument value; py_key = PyList_GET_ITEM (keys, i); py_value = PyList_GET_ITEM (values, i); @@ -1083,7 +1141,7 @@ list_item_error: hash_table_item_error: /* Free everything we have converted so far. */ - _pygi_argument_release ( (GArgument *) &hash_table, type_info, + _pygi_argument_release ( (GIArgument *) &hash_table, type_info, GI_TRANSFER_NOTHING, GI_DIRECTION_IN); hash_table = NULL; @@ -1110,7 +1168,7 @@ hash_table_release: } PyObject * -_pygi_argument_to_object (GArgument *arg, +_pygi_argument_to_object (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer) { @@ -1135,27 +1193,27 @@ _pygi_argument_to_object (GArgument *arg, } case GI_TYPE_TAG_INT8: { - object = PyInt_FromLong (arg->v_int8); + object = PYGLIB_PyLong_FromLong (arg->v_int8); break; } case GI_TYPE_TAG_UINT8: { - object = PyInt_FromLong (arg->v_uint8); + object = PYGLIB_PyLong_FromLong (arg->v_uint8); break; } case GI_TYPE_TAG_INT16: { - object = PyInt_FromLong (arg->v_int16); + object = PYGLIB_PyLong_FromLong (arg->v_int16); break; } case GI_TYPE_TAG_UINT16: { - object = PyInt_FromLong (arg->v_uint16); + object = PYGLIB_PyLong_FromLong (arg->v_uint16); break; } case GI_TYPE_TAG_INT32: { - object = PyInt_FromLong (arg->v_int32); + object = PYGLIB_PyLong_FromLong (arg->v_int32); break; } case GI_TYPE_TAG_UINT32: @@ -1195,7 +1253,7 @@ _pygi_argument_to_object (GArgument *arg, break; } - object = PyString_FromString (arg->v_string); + object = PYGLIB_PyUnicode_FromString (arg->v_string); break; case GI_TYPE_TAG_FILENAME: { @@ -1215,7 +1273,7 @@ _pygi_argument_to_object (GArgument *arg, break; } - object = PyString_FromString (string); + object = PYGLIB_PyUnicode_FromString (string); g_free (string); @@ -1249,7 +1307,7 @@ _pygi_argument_to_object (GArgument *arg, item_size = g_array_get_element_size (array); for (i = 0; i < array->len; i++) { - GArgument item; + GIArgument item; PyObject *py_item; gboolean is_struct = FALSE; @@ -1266,9 +1324,9 @@ _pygi_argument_to_object (GArgument *arg, } if (is_struct) { - item.v_pointer = &_g_array_index (array, GArgument, i); + item.v_pointer = &_g_array_index (array, GIArgument, i); } else { - memcpy (&item, &_g_array_index (array, GArgument, i), item_size); + memcpy (&item, &_g_array_index (array, GIArgument, i), item_size); } py_item = _pygi_argument_to_object (&item, item_type_info, item_transfer); @@ -1355,15 +1413,12 @@ _pygi_argument_to_object (GArgument *arg, break; } - if (transfer != GI_TRANSFER_NOTHING) - g_warning ("Transfer mode should be set to None for " - "struct types as there is no way to free " - "them safely. Ignoring transfer mode " - "to prevent a potential invalid free. " - "This may cause a leak in your application."); - + /* Only structs created in invoke can be safely marked + * GI_TRANSFER_EVERYTHING. Trust that invoke has + * filtered correctly + */ object = _pygi_struct_new ( (PyTypeObject *) py_type, arg->v_pointer, - FALSE); + transfer == GI_TRANSFER_EVERYTHING); Py_DECREF (py_type); } else { @@ -1446,7 +1501,7 @@ _pygi_argument_to_object (GArgument *arg, item_transfer = transfer == GI_TRANSFER_CONTAINER ? GI_TRANSFER_NOTHING : transfer; for (i = 0; list != NULL; list = g_slist_next (list), i++) { - GArgument item; + GIArgument item; PyObject *py_item; item.v_pointer = list->data; @@ -1470,8 +1525,8 @@ _pygi_argument_to_object (GArgument *arg, GITypeInfo *value_type_info; GITransfer item_transfer; GHashTableIter hash_table_iter; - GArgument key; - GArgument value; + GIArgument key; + GIArgument value; if (arg->v_pointer == NULL) { object = Py_None; @@ -1486,9 +1541,11 @@ _pygi_argument_to_object (GArgument *arg, key_type_info = g_type_info_get_param_type (type_info, 0); g_assert (key_type_info != NULL); + g_assert (g_type_info_get_tag (key_type_info) != GI_TYPE_TAG_VOID); value_type_info = g_type_info_get_param_type (type_info, 1); g_assert (value_type_info != NULL); + g_assert (g_type_info_get_tag (value_type_info) != GI_TYPE_TAG_VOID); item_transfer = transfer == GI_TRANSFER_CONTAINER ? GI_TRANSFER_NOTHING : transfer; @@ -1533,12 +1590,13 @@ _pygi_argument_to_object (GArgument *arg, } void -_pygi_argument_release (GArgument *arg, +_pygi_argument_release (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer, GIDirection direction) { GITypeTag type_tag; + gboolean is_out = (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT); type_tag = g_type_info_get_tag (type_info); @@ -1590,8 +1648,8 @@ _pygi_argument_release (GArgument *arg, /* Free the items */ for (i = 0; i < array->len; i++) { - GArgument *item; - item = &_g_array_index (array, GArgument, i); + GIArgument *item; + item = &_g_array_index (array, GIArgument, i); _pygi_argument_release (item, item_type_info, item_transfer, direction); } @@ -1649,7 +1707,7 @@ _pygi_argument_release (GArgument *arg, } } else if (g_struct_info_is_foreign ( (GIStructInfo*) info)) { if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING) { - pygi_struct_foreign_release_g_argument (transfer, type_info, arg); + pygi_struct_foreign_release (info, arg->v_pointer); } } else if (g_type_is_a (type, G_TYPE_BOXED)) { } else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) { @@ -1666,7 +1724,7 @@ _pygi_argument_release (GArgument *arg, if (arg->v_pointer == NULL) { return; } - if (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING) { + if (is_out && transfer == GI_TRANSFER_EVERYTHING) { g_object_unref (arg->v_pointer); } break; @@ -1701,7 +1759,7 @@ _pygi_argument_release (GArgument *arg, /* Free the items */ for (item = list; item != NULL; item = g_slist_next (item)) { - _pygi_argument_release ( (GArgument *) &item->data, item_type_info, + _pygi_argument_release ( (GIArgument *) &item->data, item_type_info, item_transfer, direction); } @@ -1754,9 +1812,9 @@ _pygi_argument_release (GArgument *arg, g_hash_table_iter_init (&hash_table_iter, hash_table); while (g_hash_table_iter_next (&hash_table_iter, &key, &value)) { - _pygi_argument_release ( (GArgument *) &key, key_type_info, + _pygi_argument_release ( (GIArgument *) &key, key_type_info, item_transfer, direction); - _pygi_argument_release ( (GArgument *) &value, value_type_info, + _pygi_argument_release ( (GIArgument *) &value, value_type_info, item_transfer, direction); } diff --git a/gi/pygi-argument.h b/gi/pygi-argument.h index 821737a..d932e8f 100644 --- a/gi/pygi-argument.h +++ b/gi/pygi-argument.h @@ -30,6 +30,8 @@ G_BEGIN_DECLS /* Private */ +gint _pygi_g_type_interface_check_object (GIBaseInfo *info, + PyObject *object); gint _pygi_g_type_info_check_object (GITypeInfo *type_info, PyObject *object, @@ -40,21 +42,21 @@ gint _pygi_g_registered_type_info_check_object (GIRegisteredTypeInfo *info, PyObject *object); -GArray* _pygi_argument_to_array (GArgument *arg, - GArgument *args[], +GArray* _pygi_argument_to_array (GIArgument *arg, + GIArgument *args[], GITypeInfo *type_info, gboolean is_method); -GArgument _pygi_argument_from_object (PyObject *object, +GIArgument _pygi_argument_from_object (PyObject *object, GITypeInfo *type_info, GITransfer transfer); -PyObject* _pygi_argument_to_object (GArgument *arg, +PyObject* _pygi_argument_to_object (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer); -void _pygi_argument_release (GArgument *arg, +void _pygi_argument_release (GIArgument *arg, GITypeInfo *type_info, GITransfer transfer, GIDirection direction); diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index 4903834..2fd446c 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -25,6 +25,7 @@ #include #include +#include static void _boxed_dealloc (PyGIBoxed *self) @@ -44,7 +45,38 @@ _boxed_dealloc (PyGIBoxed *self) } } - ( (PyGObject *) self)->ob_type->tp_free ( (PyObject *) self); + Py_TYPE( (PyGObject *) self)->tp_free ( (PyObject *) self); +} + +void * +_pygi_boxed_alloc (GIBaseInfo *info, gsize *size_out) +{ + gsize size; + + /* FIXME: Remove when bgo#622711 is fixed */ + if (g_registered_type_info_get_g_type (info) == G_TYPE_VALUE) { + size = sizeof (GValue); + } else { + switch (g_base_info_get_type (info)) { + case GI_INFO_TYPE_UNION: + size = g_union_info_get_size ( (GIUnionInfo *) info); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + size = g_struct_info_get_size ( (GIStructInfo *) info); + break; + default: + PyErr_Format (PyExc_TypeError, + "info should be Boxed or Union, not '%d'", + g_base_info_get_type (info)); + return NULL; + } + } + + if( size_out != NULL) + *size_out = size; + + return g_slice_alloc0 (size); } static PyObject * @@ -55,7 +87,7 @@ _boxed_new (PyTypeObject *type, static char *kwlist[] = { NULL }; GIBaseInfo *info; - gsize size; + gsize size = 0; gpointer boxed; PyGIBoxed *self = NULL; @@ -71,22 +103,7 @@ _boxed_new (PyTypeObject *type, return NULL; } - switch (g_base_info_get_type (info)) { - case GI_INFO_TYPE_UNION: - size = g_union_info_get_size ( (GIUnionInfo *) info); - break; - case GI_INFO_TYPE_BOXED: - case GI_INFO_TYPE_STRUCT: - size = g_struct_info_get_size ( (GIStructInfo *) info); - break; - default: - PyErr_Format (PyExc_TypeError, - "info should be Boxed or Union, not '%d'", - g_base_info_get_type (info)); - return NULL; - } - - boxed = g_slice_alloc0 (size); + boxed = _pygi_boxed_alloc (info, &size); if (boxed == NULL) { PyErr_NoMemory(); goto out; @@ -116,41 +133,7 @@ _boxed_init (PyObject *self, return 0; } - -PyTypeObject PyGIBoxed_Type = { - PyObject_HEAD_INIT (NULL) - 0, - "gi.Boxed", /* tp_name */ - sizeof (PyGIBoxed), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) _boxed_dealloc, /* tp_dealloc */ - (printfunc) NULL, /* tp_print */ - (getattrfunc) NULL, /* tp_getattr */ - (setattrfunc) NULL, /* tp_setattr */ - (cmpfunc) NULL, /* tp_compare */ - (reprfunc) NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - (hashfunc) NULL, /* tp_hash */ - (ternaryfunc) NULL, /* tp_call */ - (reprfunc) NULL, /* tp_str */ - (getattrofunc) NULL, /* tp_getattro */ - (setattrofunc) NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* tp_doc */ - (traverseproc) NULL, /* tp_traverse */ - (inquiry) NULL, /* tp_clear */ - (richcmpfunc) NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) NULL, /* tp_iter */ - (iternextfunc) NULL, /* tp_iternext */ - NULL, /* tp_methods */ - NULL, /* tp_members */ - NULL, /* tp_getset */ - (PyTypeObject *) NULL, /* tp_base */ -}; +PYGLIB_DEFINE_TYPE("gi.Boxed", PyGIBoxed_Type, PyGIBoxed); PyObject * _pygi_boxed_new (PyTypeObject *type, @@ -185,10 +168,13 @@ _pygi_boxed_new (PyTypeObject *type, void _pygi_boxed_register_types (PyObject *m) { - PyGIBoxed_Type.ob_type = &PyType_Type; + Py_TYPE(&PyGIBoxed_Type) = &PyType_Type; PyGIBoxed_Type.tp_base = &PyGBoxed_Type; PyGIBoxed_Type.tp_new = (newfunc) _boxed_new; PyGIBoxed_Type.tp_init = (initproc) _boxed_init; + PyGIBoxed_Type.tp_dealloc = (destructor) _boxed_dealloc; + PyGIBoxed_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + if (PyType_Ready (&PyGIBoxed_Type)) return; if (PyModule_AddObject (m, "Boxed", (PyObject *) &PyGIBoxed_Type)) diff --git a/gi/pygi-boxed.h b/gi/pygi-boxed.h index 4f84060..a84ec4e 100644 --- a/gi/pygi-boxed.h +++ b/gi/pygi-boxed.h @@ -28,10 +28,12 @@ G_BEGIN_DECLS extern PyTypeObject PyGIBoxed_Type; -PyObject * -_pygi_boxed_new (PyTypeObject *type, - gpointer boxed, - gboolean free_on_dealloc); +PyObject * _pygi_boxed_new (PyTypeObject *type, + gpointer boxed, + gboolean free_on_dealloc); + +void * _pygi_boxed_alloc (GIBaseInfo *info, + gsize *size); void _pygi_boxed_register_types (PyObject *m); diff --git a/gi/pygi-callbacks.c b/gi/pygi-callbacks.c index 6fdc1ce..bae4001 100644 --- a/gi/pygi-callbacks.c +++ b/gi/pygi-callbacks.c @@ -95,7 +95,8 @@ _pygi_scan_for_callbacks (GIFunctionInfo *function_info, interface_type = g_base_info_get_type (interface_info); if (interface_type == GI_INFO_TYPE_CALLBACK && ! (strcmp (g_base_info_get_namespace ( (GIBaseInfo*) interface_info), "GLib") == 0 && - strcmp (g_base_info_get_name ( (GIBaseInfo*) interface_info), "DestroyNotify") == 0)) { + (strcmp (g_base_info_get_name ( (GIBaseInfo*) interface_info), "DestroyNotify") == 0 || + (strcmp (g_base_info_get_name ( (GIBaseInfo*) interface_info), "FreeFunc") == 0)))) { if (*callback_index != G_MAXUINT8) { PyErr_Format (PyExc_TypeError, "Function %s.%s has multiple callbacks, not supported", g_base_info_get_namespace ( (GIBaseInfo*) function_info), @@ -108,11 +109,8 @@ _pygi_scan_for_callbacks (GIFunctionInfo *function_info, g_base_info_unref (interface_info); } destroy = g_arg_info_get_destroy (arg_info); - if (is_method) - --destroy; + closure = g_arg_info_get_closure (arg_info); - if (is_method) - --closure; direction = g_arg_info_get_direction (arg_info); if (destroy > 0 && destroy < n_args) { @@ -200,7 +198,8 @@ _pygi_create_callback (GIBaseInfo *function_info, if (!found_py_function || (py_function == Py_None || !PyCallable_Check (py_function))) { - PyErr_Format (PyExc_TypeError, "Error invoking %s.%s: Invalid callback given for argument %s", + PyErr_Format (PyExc_TypeError, "Error invoking %s.%s: Unexpected value " + "for argument '%s'", g_base_info_get_namespace ( (GIBaseInfo*) function_info), g_base_info_get_name ( (GIBaseInfo*) function_info), g_base_info_get_name ( (GIBaseInfo*) callback_arg)); diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c index b26d5b1..1e2ce05 100644 --- a/gi/pygi-closure.c +++ b/gi/pygi-closure.c @@ -28,7 +28,7 @@ static GSList* async_free_list; -static GArgument * +static GIArgument * _pygi_closure_convert_ffi_arguments (GICallableInfo *callable_info, void **args) { gint num_args, i; @@ -36,10 +36,10 @@ _pygi_closure_convert_ffi_arguments (GICallableInfo *callable_info, void **args) GITypeInfo *arg_type; GITypeTag tag; GIDirection direction; - GArgument *g_args; + GIArgument *g_args; num_args = g_callable_info_get_n_args (callable_info); - g_args = g_new0 (GArgument, num_args); + g_args = g_new0 (GIArgument, num_args); for (i = 0; i < num_args; i++) { arg_info = g_callable_info_get_arg (callable_info, i); @@ -130,13 +130,13 @@ _pygi_closure_convert_ffi_arguments (GICallableInfo *callable_info, void **args) static gboolean _pygi_closure_convert_arguments (GICallableInfo *callable_info, void **args, void *user_data, PyObject **py_args, - GArgument **out_args) + GIArgument **out_args) { int n_args = g_callable_info_get_n_args (callable_info); int n_in_args = 0; int n_out_args = 0; int i; - GArgument *g_args = NULL; + GIArgument *g_args = NULL; *py_args = NULL; *py_args = PyTuple_New (n_args); @@ -144,7 +144,7 @@ _pygi_closure_convert_arguments (GICallableInfo *callable_info, void **args, goto error; *out_args = NULL; - *out_args = g_new0 (GArgument, n_args); + *out_args = g_new0 (GIArgument, n_args); g_args = _pygi_closure_convert_ffi_arguments (callable_info, args); for (i = 0; i < n_args; i++) { @@ -156,7 +156,7 @@ _pygi_closure_convert_arguments (GICallableInfo *callable_info, void **args, GITypeTag arg_tag = g_type_info_get_tag (arg_type); GITransfer transfer = g_arg_info_get_ownership_transfer (arg_info); PyObject *value; - GArgument *arg; + GIArgument *arg; if (direction == GI_DIRECTION_IN && arg_tag == GI_TYPE_TAG_VOID && g_type_info_is_pointer (arg_type)) { @@ -170,9 +170,9 @@ _pygi_closure_convert_arguments (GICallableInfo *callable_info, void **args, } } else { if (direction == GI_DIRECTION_IN) - arg = (GArgument*) &g_args[i]; + arg = (GIArgument*) &g_args[i]; else - arg = (GArgument*) g_args[i].v_pointer; + arg = (GIArgument*) g_args[i].v_pointer; value = _pygi_argument_to_object (arg, arg_type, transfer); if (value == NULL) { @@ -214,7 +214,7 @@ error: static void _pygi_closure_set_out_arguments (GICallableInfo *callable_info, - PyObject *py_retval, GArgument *out_args, + PyObject *py_retval, GIArgument *out_args, void *resp) { int n_args, i, i_py_retval, i_out_args; @@ -225,15 +225,15 @@ _pygi_closure_set_out_arguments (GICallableInfo *callable_info, return_type_info = g_callable_info_get_return_type (callable_info); return_type_tag = g_type_info_get_tag (return_type_info); if (return_type_tag != GI_TYPE_TAG_VOID) { - GArgument arg; + GIArgument arg; GITransfer transfer = g_callable_info_get_caller_owns (callable_info); if (PyTuple_Check (py_retval)) { PyObject *item = PyTuple_GET_ITEM (py_retval, 0); arg = _pygi_argument_from_object (item, return_type_info, transfer); - * ( (GArgument*) resp) = arg; + * ( (GIArgument*) resp) = arg; } else { arg = _pygi_argument_from_object (py_retval, return_type_info, transfer); - * ( (GArgument*) resp) = arg; + * ( (GIArgument*) resp) = arg; } i_py_retval++; } @@ -248,14 +248,14 @@ _pygi_closure_set_out_arguments (GICallableInfo *callable_info, if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { GITransfer transfer = g_arg_info_get_ownership_transfer (arg_info); - GArgument arg; + GIArgument arg; if (PyTuple_Check (py_retval)) { PyObject *item = PyTuple_GET_ITEM (py_retval, i_py_retval); arg = _pygi_argument_from_object (item, type_info, transfer); - * ( (GArgument*) out_args[i_out_args].v_pointer) = arg; + * ( (GIArgument*) out_args[i_out_args].v_pointer) = arg; } else if (i_py_retval == 0) { arg = _pygi_argument_from_object (py_retval, type_info, transfer); - * ( (GArgument*) out_args[i_out_args].v_pointer) = arg; + * ( (GIArgument*) out_args[i_out_args].v_pointer) = arg; } else g_assert_not_reached(); @@ -280,7 +280,7 @@ _pygi_closure_handle (ffi_cif *cif, GITypeInfo *return_type; PyObject *retval; PyObject *py_args; - GArgument *out_args = NULL; + GIArgument *out_args = NULL; /* Lock the GIL as we are coming into this code without the lock and we may be executing python code */ diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c index 08d50ad..095f6cb 100644 --- a/gi/pygi-foreign-cairo.c +++ b/gi/pygi-foreign-cairo.c @@ -22,16 +22,24 @@ */ #include + +#if PY_VERSION_HEX < 0x03000000 #include +#else +#include +#endif + Pycairo_CAPI_t *Pycairo_CAPI; #include "pygi-foreign.h" +#include + PyObject * cairo_context_to_arg (PyObject *value, GITypeInfo *type_info, GITransfer transfer, - GArgument *arg) + GIArgument *arg) { cairo_t *cr; @@ -47,7 +55,7 @@ cairo_context_to_arg (PyObject *value, } PyObject * -cairo_context_from_arg (GITypeInfo *type_info, GArgument *arg) +cairo_context_from_arg (GITypeInfo *type_info, GIArgument *arg) { cairo_t *context = (cairo_t*) arg; @@ -57,10 +65,10 @@ cairo_context_from_arg (GITypeInfo *type_info, GArgument *arg) } PyObject * -cairo_context_release_arg (GITransfer transfer, GITypeInfo *type_info, - GArgument *arg) +cairo_context_release (GIBaseInfo *base_info, + gpointer struct_) { - cairo_destroy ( (cairo_t*) arg->v_pointer); + cairo_destroy ( (cairo_t*) struct_); Py_RETURN_NONE; } @@ -69,7 +77,7 @@ PyObject * cairo_surface_to_arg (PyObject *value, GITypeInfo *type_info, GITransfer transfer, - GArgument *arg) + GIArgument *arg) { cairo_surface_t *surface; @@ -86,7 +94,7 @@ cairo_surface_to_arg (PyObject *value, } PyObject * -cairo_surface_from_arg (GITypeInfo *type_info, GArgument *arg) +cairo_surface_from_arg (GITypeInfo *type_info, GIArgument *arg) { cairo_surface_t *surface = (cairo_surface_t*) arg; @@ -96,36 +104,31 @@ cairo_surface_from_arg (GITypeInfo *type_info, GArgument *arg) } PyObject * -cairo_surface_release_arg (GITransfer transfer, GITypeInfo *type_info, - GArgument *arg) +cairo_surface_release (GIBaseInfo *base_info, + gpointer struct_) { - cairo_surface_destroy ( (cairo_surface_t*) arg->v_pointer); + cairo_surface_destroy ( (cairo_surface_t*) struct_); Py_RETURN_NONE; } -PyMODINIT_FUNC -init_gi_cairo (void) -{ - PyObject *m; - - m = Py_InitModule ("_gi_cairo", NULL); - if (m == NULL) { - return; - } +static PyMethodDef _gi_cairo_functions[] = {}; +PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo") +{ Pycairo_IMPORT; if (Pycairo_CAPI == NULL) - return; + return 0; pygi_register_foreign_struct ("cairo", "Context", cairo_context_to_arg, cairo_context_from_arg, - cairo_context_release_arg); + cairo_context_release); pygi_register_foreign_struct ("cairo", "Surface", cairo_surface_to_arg, cairo_surface_from_arg, - cairo_surface_release_arg); + cairo_surface_release); } +PYGLIB_MODULE_END; diff --git a/gi/pygi-foreign-gvariant.c b/gi/pygi-foreign-gvariant.c new file mode 100644 index 0000000..ac16395 --- /dev/null +++ b/gi/pygi-foreign-gvariant.c @@ -0,0 +1,63 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2010 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "pygobject.h" + +#include "pygi-private.h" +#include "pygi-foreign-gvariant.h" + +PyObject * +g_variant_to_arg (PyObject *value, + GITypeInfo *type_info, + GITransfer transfer, + GIArgument *arg) +{ + g_assert (transfer == GI_TRANSFER_NOTHING); + + /* TODO check that value is a PyGPointer */ + + arg->v_pointer = (GVariant *) ( (PyGPointer *) value)->pointer; + Py_RETURN_NONE; +} + +PyObject * +g_variant_from_arg (GITypeInfo *type_info, + GIArgument *arg) +{ + GVariant *variant = (GVariant *) arg; + GITypeInfo *interface_info = g_type_info_get_interface (type_info); + PyObject *type = _pygi_type_import_by_gi_info (interface_info); + + g_variant_ref_sink (variant); + + return _pygi_struct_new ( (PyTypeObject *) type, variant, FALSE); +} + +PyObject * +g_variant_release_foreign (GIBaseInfo *base_info, + gpointer struct_) +{ + g_variant_unref ( (GVariant *) struct_); + Py_RETURN_NONE; +} + diff --git a/gi/pygi-foreign-gvariant.h b/gi/pygi-foreign-gvariant.h new file mode 100644 index 0000000..6de8c57 --- /dev/null +++ b/gi/pygi-foreign-gvariant.h @@ -0,0 +1,41 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2010 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __PYGI_FOREIGN_G_VARIANT_H__ +#define __PYGI_FOREIGN_G_VARIANT_H__ + +#include "pygi-foreign.h" + +PyObject *g_variant_to_arg(PyObject *value, + GITypeInfo *type_info, + GITransfer transfer, + GIArgument *arg); + +PyObject *g_variant_from_arg(GITypeInfo *type_info, + GIArgument *arg); + +PyObject *g_variant_release_foreign (GIBaseInfo *base_info, + gpointer struct_); + +#endif /* __PYGI_FOREIGN_G_VARIANT_H__ */ + diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c index 13a0f77..f80b43c 100644 --- a/gi/pygi-foreign.c +++ b/gi/pygi-foreign.c @@ -23,6 +23,7 @@ */ #include "pygi-foreign.h" +#include "pygi-foreign-gvariant.h" #include #include @@ -30,62 +31,87 @@ typedef struct { const char *namespace; const char *name; - PyGIArgOverrideToGArgumentFunc to_func; - PyGIArgOverrideFromGArgumentFunc from_func; - PyGIArgOverrideReleaseGArgumentFunc release_func; + PyGIArgOverrideToGIArgumentFunc to_func; + PyGIArgOverrideFromGIArgumentFunc from_func; + PyGIArgOverrideReleaseFunc release_func; } PyGIForeignStruct; static GPtrArray *foreign_structs = NULL; +void +init_foreign_structs () +{ + foreign_structs = g_ptr_array_new (); + + pygi_register_foreign_struct ("GLib", + "Variant", + g_variant_to_arg, + g_variant_from_arg, + g_variant_release_foreign); +} + static PyGIForeignStruct * -pygi_struct_foreign_lookup (GITypeInfo *type_info) +do_lookup (const gchar *namespace, const gchar *name) { gint i; - PyObject *module; - gchar *module_name; - GIBaseInfo *base_info; - const gchar *namespace; - const gchar *name; - - base_info = g_type_info_get_interface (type_info); - if (base_info == NULL) { - PyErr_Format (PyExc_ValueError, "Couldn't resolve the type of this foreign struct"); - return NULL; + for (i = 0; i < foreign_structs->len; i++) { + PyGIForeignStruct *foreign_struct = \ + g_ptr_array_index (foreign_structs, i); + + if ( (strcmp (namespace, foreign_struct->namespace) == 0) && + (strcmp (name, foreign_struct->name) == 0)) { + return foreign_struct; + } + } + return NULL; +} + +static PyGIForeignStruct * +pygi_struct_foreign_lookup (GIBaseInfo *base_info) +{ + PyGIForeignStruct *result; + const gchar *namespace = g_base_info_get_namespace (base_info); + const gchar *name = g_base_info_get_name (base_info); + + if (foreign_structs == NULL) { + init_foreign_structs (); } - namespace = g_base_info_get_namespace (base_info); - name = g_base_info_get_name (base_info); + result = do_lookup (namespace, name); - module_name = g_strconcat ("gi._gi_", g_base_info_get_namespace (base_info), NULL); - module = PyImport_ImportModule (module_name); - g_free (module_name); + if (result == NULL) { + gchar *module_name = g_strconcat ("gi._gi_", namespace, NULL); + PyObject *module = PyImport_ImportModule (module_name); - if (foreign_structs != NULL) { - for (i = 0; i < foreign_structs->len; i++) { - PyGIForeignStruct *foreign_struct = \ - g_ptr_array_index (foreign_structs, i); + g_free (module_name); - if ( (strcmp (namespace, foreign_struct->namespace) == 0) && - (strcmp (name, foreign_struct->name) == 0)) { - g_base_info_unref (base_info); - return foreign_struct; - } + if (module == NULL) + PyErr_Clear (); + else { + Py_DECREF (module); + result = do_lookup (namespace, name); } } - g_base_info_unref (base_info); + if (result == NULL) { + PyErr_Format (PyExc_TypeError, + "Couldn't find conversion for foreign struct '%s.%s'", + namespace, + name); + } - PyErr_Format (PyExc_TypeError, "Couldn't find conversion for foreign struct '%s.%s'", namespace, name); - return NULL; + return result; } PyObject * -pygi_struct_foreign_convert_to_g_argument (PyObject *value, +pygi_struct_foreign_convert_to_g_argument (PyObject *value, GITypeInfo *type_info, GITransfer transfer, - GArgument *arg) + GIArgument *arg) { - PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (type_info); + GIBaseInfo *base_info = g_type_info_get_interface (type_info); + PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info); + g_base_info_unref (base_info); if (foreign_struct == NULL) return NULL; @@ -98,9 +124,12 @@ pygi_struct_foreign_convert_to_g_argument (PyObject *value, PyObject * pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info, - GArgument *arg) + GIArgument *arg) { - PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (type_info); + GIBaseInfo *base_info = g_type_info_get_interface (type_info); + PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info); + g_base_info_unref (base_info); + if (foreign_struct == NULL) return NULL; @@ -109,11 +138,10 @@ pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info, } PyObject * -pygi_struct_foreign_release_g_argument (GITransfer transfer, - GITypeInfo *type_info, - GArgument *arg) +pygi_struct_foreign_release (GIBaseInfo *base_info, + gpointer struct_) { - PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (type_info); + PyGIForeignStruct *foreign_struct = pygi_struct_foreign_lookup (base_info); if (foreign_struct == NULL) return NULL; @@ -121,7 +149,7 @@ pygi_struct_foreign_release_g_argument (GITransfer transfer, if (!foreign_struct->release_func) Py_RETURN_NONE; - if (!foreign_struct->release_func (transfer, type_info, arg)) + if (!foreign_struct->release_func (base_info, struct_)) return NULL; Py_RETURN_NONE; @@ -130,9 +158,9 @@ pygi_struct_foreign_release_g_argument (GITransfer transfer, void pygi_register_foreign_struct_real (const char* namespace_, const char* name, - PyGIArgOverrideToGArgumentFunc to_func, - PyGIArgOverrideFromGArgumentFunc from_func, - PyGIArgOverrideReleaseGArgumentFunc release_func) + PyGIArgOverrideToGIArgumentFunc to_func, + PyGIArgOverrideFromGIArgumentFunc from_func, + PyGIArgOverrideReleaseFunc release_func) { PyGIForeignStruct *new_struct = g_slice_new0 (PyGIForeignStruct); new_struct->namespace = namespace_; @@ -141,8 +169,5 @@ pygi_register_foreign_struct_real (const char* namespace_, new_struct->from_func = from_func; new_struct->release_func = release_func; - if (foreign_structs == NULL) - foreign_structs = g_ptr_array_new (); - g_ptr_array_add (foreign_structs, new_struct); } diff --git a/gi/pygi-foreign.h b/gi/pygi-foreign.h index 9a35bd8..b57f892 100644 --- a/gi/pygi-foreign.h +++ b/gi/pygi-foreign.h @@ -33,17 +33,16 @@ PyObject *pygi_struct_foreign_convert_to_g_argument (PyObject *value, GITypeInfo *type_info, GITransfer transfer, - GArgument *arg); + GIArgument *arg); PyObject *pygi_struct_foreign_convert_from_g_argument (GITypeInfo *type_info, - GArgument *arg); -PyObject *pygi_struct_foreign_release_g_argument (GITransfer transfer, - GITypeInfo *type_info, - GArgument *arg); + GIArgument *arg); +PyObject *pygi_struct_foreign_release (GITypeInfo *type_info, + gpointer struct_); void pygi_register_foreign_struct_real (const char* namespace_, const char* name, - PyGIArgOverrideToGArgumentFunc to_func, - PyGIArgOverrideFromGArgumentFunc from_func, - PyGIArgOverrideReleaseGArgumentFunc release_func); + PyGIArgOverrideToGIArgumentFunc to_func, + PyGIArgOverrideFromGIArgumentFunc from_func, + PyGIArgOverrideReleaseFunc release_func); #endif /* __PYGI_FOREIGN_H__ */ diff --git a/gi/pygi-info.c b/gi/pygi-info.c index 7888ada..feeccf7 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -24,44 +24,7 @@ #include "pygi-private.h" #include - -#define _PyGI_DEFINE_INFO_TYPE(name, cname, base) \ -static PyMethodDef _Py##cname##_methods[]; \ -PyTypeObject Py##cname##_Type = { \ - PyObject_HEAD_INIT(NULL) \ - 0, \ - "gi." name, /* tp_name */ \ - sizeof(PyGIBaseInfo), /* tp_basicsize */ \ - 0, /* tp_itemsize */ \ - (destructor)NULL, /* tp_dealloc */ \ - (printfunc)NULL, /* tp_print */ \ - (getattrfunc)NULL, /* tp_getattr */ \ - (setattrfunc)NULL, /* tp_setattr */ \ - (cmpfunc)NULL, /* tp_compare */ \ - (reprfunc)NULL, /* tp_repr */ \ - NULL, /* tp_as_number */ \ - NULL, /* tp_as_sequence */ \ - NULL, /* tp_as_mapping */ \ - (hashfunc)NULL, /* tp_hash */ \ - (ternaryfunc)NULL, /* tp_call */ \ - (reprfunc)NULL, /* tp_str */ \ - (getattrofunc)NULL, /* tp_getattro */ \ - (setattrofunc)NULL, /* tp_setattro */ \ - NULL, /* tp_as_buffer */ \ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \ - NULL, /* tp_doc */ \ - (traverseproc)NULL, /* tp_traverse */ \ - (inquiry)NULL, /* tp_clear */ \ - (richcmpfunc)NULL, /* tp_richcompare */ \ - offsetof(PyGIBaseInfo, inst_weakreflist), /* tp_weaklistoffset */ \ - (getiterfunc)NULL, /* tp_iter */ \ - (iternextfunc)NULL, /* tp_iternext */ \ - _Py##cname##_methods, /* tp_methods */ \ - NULL, /* tp_members */ \ - NULL, /* tp_getset */ \ - &base /* tp_base */ \ -} - +#include /* BaseInfo */ @@ -74,7 +37,7 @@ _base_info_dealloc (PyGIBaseInfo *self) g_base_info_unref (self->info); - self->ob_type->tp_free ( (PyObject *) self); + Py_TYPE( (PyObject *) self)->tp_free ( (PyObject *) self); } static int @@ -88,55 +51,26 @@ _base_info_traverse (PyGIBaseInfo *self, static PyObject * _base_info_repr (PyGIBaseInfo *self) { - return PyString_FromFormat ("<%s object (%s) at 0x%p>", - self->ob_type->tp_name, g_base_info_get_name (self->info), (void *) self); + return PYGLIB_PyUnicode_FromFormat ("<%s object (%s) at 0x%p>", + Py_TYPE( (PyObject *) self)->tp_name, + g_base_info_get_name (self->info), + (void *) self); } static PyMethodDef _PyGIBaseInfo_methods[]; -PyTypeObject PyGIBaseInfo_Type = { - PyObject_HEAD_INIT (NULL) - 0, - "gi.BaseInfo", /* tp_name */ - sizeof (PyGIBaseInfo), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) _base_info_dealloc, /* tp_dealloc */ - (printfunc) NULL, /* tp_print */ - (getattrfunc) NULL, /* tp_getattr */ - (setattrfunc) NULL, /* tp_setattr */ - (cmpfunc) NULL, /* tp_compare */ - (reprfunc) _base_info_repr, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - (hashfunc) NULL, /* tp_hash */ - (ternaryfunc) NULL, /* tp_call */ - (reprfunc) NULL, /* tp_str */ - (getattrofunc) NULL, /* tp_getattro */ - (setattrofunc) NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HAVE_GC, /* tp_flags */ - NULL, /* tp_doc */ - (traverseproc) _base_info_traverse, /* tp_traverse */ - (inquiry) NULL, /* tp_clear */ - (richcmpfunc) NULL, /* tp_richcompare */ - offsetof (PyGIBaseInfo, inst_weakreflist), /* tp_weaklistoffset */ - (getiterfunc) NULL, /* tp_iter */ - (iternextfunc) NULL, /* tp_iternext */ - _PyGIBaseInfo_methods, /* tp_methods */ -}; +PYGLIB_DEFINE_TYPE("gi.BaseInfo", PyGIBaseInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_base_info_get_name (PyGIBaseInfo *self) { - return PyString_FromString (g_base_info_get_name (self->info)); + return PYGLIB_PyUnicode_FromString (g_base_info_get_name (self->info)); } static PyObject * _wrap_g_base_info_get_namespace (PyGIBaseInfo *self) { - return PyString_FromString (g_base_info_get_namespace (self->info)); + return PYGLIB_PyUnicode_FromString (g_base_info_get_namespace (self->info)); } static PyObject * @@ -255,7 +189,7 @@ _pygi_object_get_gi_info (PyObject *object, } if (!PyObject_TypeCheck (py_info, type)) { PyErr_Format (PyExc_TypeError, "attribute '__info__' must be %s, not %s", - type->tp_name, py_info->ob_type->tp_name); + type->tp_name, Py_TYPE(&py_info)->tp_name); goto out; } @@ -270,7 +204,7 @@ out: /* CallableInfo */ -_PyGI_DEFINE_INFO_TYPE ("CallableInfo", GICallableInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.CallableInfo", PyGICallableInfo_Type, PyGIBaseInfo); static PyMethodDef _PyGICallableInfo_methods[] = { { NULL, NULL, 0 } @@ -278,7 +212,7 @@ static PyMethodDef _PyGICallableInfo_methods[] = { /* FunctionInfo */ -_PyGI_DEFINE_INFO_TYPE ("FunctionInfo", GIFunctionInfo, PyGICallableInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.FunctionInfo", PyGIFunctionInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_function_info_is_constructor (PyGIBaseInfo *self) @@ -467,7 +401,7 @@ static PyMethodDef _PyGIFunctionInfo_methods[] = { /* RegisteredTypeInfo */ -_PyGI_DEFINE_INFO_TYPE ("RegisteredTypeInfo", GIRegisteredTypeInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.RegisteredTypeInfo", PyGIRegisteredTypeInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_registered_type_info_get_g_type (PyGIBaseInfo *self) @@ -486,7 +420,7 @@ static PyMethodDef _PyGIRegisteredTypeInfo_methods[] = { /* GIStructInfo */ -_PyGI_DEFINE_INFO_TYPE ("StructInfo", GIStructInfo, PyGIRegisteredTypeInfo_Type); +PYGLIB_DEFINE_TYPE ("StructInfo", PyGIStructInfo_Type, PyGIBaseInfo); static PyObject * _get_fields (PyGIBaseInfo *self, GIInfoType info_type) @@ -832,7 +766,7 @@ pygi_g_struct_info_is_simple (GIStructInfo *struct_info) /* EnumInfo */ -_PyGI_DEFINE_INFO_TYPE ("EnumInfo", GIEnumInfo, PyGIRegisteredTypeInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.EnumInfo", PyGIEnumInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_enum_info_get_values (PyGIBaseInfo *self) @@ -877,7 +811,7 @@ static PyMethodDef _PyGIEnumInfo_methods[] = { /* ObjectInfo */ -_PyGI_DEFINE_INFO_TYPE ("ObjectInfo", GIObjectInfo, PyGIRegisteredTypeInfo_Type); +PYGLIB_DEFINE_TYPE ("ObjectInfo", PyGIObjectInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_object_info_get_parent (PyGIBaseInfo *self) @@ -970,7 +904,7 @@ static PyMethodDef _PyGIObjectInfo_methods[] = { /* GIInterfaceInfo */ -_PyGI_DEFINE_INFO_TYPE ("InterfaceInfo", GIInterfaceInfo, PyGIRegisteredTypeInfo_Type); +PYGLIB_DEFINE_TYPE ("InterfaceInfo", PyGIInterfaceInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_interface_info_get_methods (PyGIBaseInfo *self) @@ -1028,13 +962,13 @@ static PyMethodDef _PyGIInterfaceInfo_methods[] = { }; /* GIConstantInfo */ -_PyGI_DEFINE_INFO_TYPE ("ConstantInfo", GIConstantInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.ConstantInfo", PyGIConstantInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_constant_info_get_value (PyGIBaseInfo *self) { GITypeInfo *type_info; - GArgument value; + GIArgument value; PyObject *py_value; if (g_constant_info_get_value ( (GIConstantInfo *) self->info, &value) < 0) { @@ -1057,7 +991,7 @@ static PyMethodDef _PyGIConstantInfo_methods[] = { }; /* GIValueInfo */ -_PyGI_DEFINE_INFO_TYPE ("ValueInfo", GIValueInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.ValueInfo", PyGIValueInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_value_info_get_value (PyGIBaseInfo *self) @@ -1066,7 +1000,7 @@ _wrap_g_value_info_get_value (PyGIBaseInfo *self) value = g_value_info_get_value ( (GIValueInfo *) self->info); - return PyInt_FromLong (value); + return PYGLIB_PyLong_FromLong (value); } @@ -1077,7 +1011,7 @@ static PyMethodDef _PyGIValueInfo_methods[] = { /* GIFieldInfo */ -_PyGI_DEFINE_INFO_TYPE ("FieldInfo", GIFieldInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.FieldInfo", PyGIFieldInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_field_info_get_value (PyGIBaseInfo *self, @@ -1088,10 +1022,10 @@ _wrap_g_field_info_get_value (PyGIBaseInfo *self, GIInfoType container_info_type; gpointer pointer; GITypeInfo *field_type_info; - GArgument value; + GIArgument value; PyObject *py_value = NULL; - memset(&value, 0, sizeof(GArgument)); + memset(&value, 0, sizeof(GIArgument)); if (!PyArg_ParseTuple (args, "O:FieldInfo.get_value", &instance)) { return NULL; @@ -1197,7 +1131,7 @@ _wrap_g_field_info_set_value (PyGIBaseInfo *self, GIInfoType container_info_type; gpointer pointer; GITypeInfo *field_type_info; - GArgument value; + GIArgument value; PyObject *retval = NULL; if (!PyArg_ParseTuple (args, "OO:FieldInfo.set_value", &instance, &py_value)) { @@ -1333,14 +1267,14 @@ static PyMethodDef _PyGIFieldInfo_methods[] = { /* GIUnresolvedInfo */ -_PyGI_DEFINE_INFO_TYPE ("UnresolvedInfo", GIUnresolvedInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.UnresolvedInfo", PyGIUnresolvedInfo_Type, PyGIBaseInfo); static PyMethodDef _PyGIUnresolvedInfo_methods[] = { { NULL, NULL, 0 } }; /* GIVFuncInfo */ -_PyGI_DEFINE_INFO_TYPE ("VFuncInfo", GIVFuncInfo, PyGIBaseInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.VFuncInfo", PyGIVFuncInfo_Type, PyGIBaseInfo); static PyMethodDef _PyGIVFuncInfo_methods[] = { { NULL, NULL, 0 } @@ -1348,7 +1282,7 @@ static PyMethodDef _PyGIVFuncInfo_methods[] = { /* GIUnionInfo */ -_PyGI_DEFINE_INFO_TYPE ("UnionInfo", GIUnionInfo, PyGIRegisteredTypeInfo_Type); +PYGLIB_DEFINE_TYPE ("gi.UnionInfo", PyGIUnionInfo_Type, PyGIBaseInfo); static PyObject * _wrap_g_union_info_get_fields (PyGIBaseInfo *self) @@ -1458,27 +1392,61 @@ _pygi_g_base_info_get_fullname (GIBaseInfo *info) void _pygi_info_register_types (PyObject *m) { -#define _PyGI_REGISTER_TYPE(m, type, name) \ - type.ob_type = &PyType_Type; \ +#define _PyGI_REGISTER_TYPE(m, type, cname, base) \ + Py_TYPE(&type) = &PyType_Type; \ + type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); \ + type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); \ + type.tp_methods = _PyGI##cname##_methods; \ + type.tp_base = &base; \ if (PyType_Ready(&type)) \ return; \ - if (PyModule_AddObject(m, name, (PyObject *)&type)) \ + if (PyModule_AddObject(m, #cname, (PyObject *)&type)) \ return - _PyGI_REGISTER_TYPE (m, PyGIBaseInfo_Type, "BaseInfo"); - _PyGI_REGISTER_TYPE (m, PyGIUnresolvedInfo_Type, "UnresolvedInfo"); - _PyGI_REGISTER_TYPE (m, PyGICallableInfo_Type, "CallableInfo"); - _PyGI_REGISTER_TYPE (m, PyGIFunctionInfo_Type, "FunctionInfo"); - _PyGI_REGISTER_TYPE (m, PyGIRegisteredTypeInfo_Type, "RegisteredTypeInfo"); - _PyGI_REGISTER_TYPE (m, PyGIStructInfo_Type, "StructInfo"); - _PyGI_REGISTER_TYPE (m, PyGIEnumInfo_Type, "EnumInfo"); - _PyGI_REGISTER_TYPE (m, PyGIObjectInfo_Type, "ObjectInfo"); - _PyGI_REGISTER_TYPE (m, PyGIInterfaceInfo_Type, "InterfaceInfo"); - _PyGI_REGISTER_TYPE (m, PyGIConstantInfo_Type, "ConstantInfo"); - _PyGI_REGISTER_TYPE (m, PyGIValueInfo_Type, "ValueInfo"); - _PyGI_REGISTER_TYPE (m, PyGIFieldInfo_Type, "FieldInfo"); - _PyGI_REGISTER_TYPE (m, PyGIVFuncInfo_Type, "VFuncInfo"); - _PyGI_REGISTER_TYPE (m, PyGIUnionInfo_Type, "UnionInfo"); + Py_TYPE(&PyGIBaseInfo_Type) = &PyType_Type; + + PyGIBaseInfo_Type.tp_dealloc = (destructor) _base_info_dealloc; + PyGIBaseInfo_Type.tp_repr = (reprfunc) _base_info_repr; + PyGIBaseInfo_Type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_GC); + PyGIBaseInfo_Type.tp_traverse = (traverseproc) _base_info_traverse; + PyGIBaseInfo_Type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); + PyGIBaseInfo_Type.tp_methods = _PyGIBaseInfo_methods; + + if (PyType_Ready(&PyGIBaseInfo_Type)) + return; + + if (PyModule_AddObject(m, "BaseInfo", (PyObject *)&PyGIBaseInfo_Type)) + return; + + _PyGI_REGISTER_TYPE (m, PyGIUnresolvedInfo_Type, UnresolvedInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGICallableInfo_Type, CallableInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIFunctionInfo_Type, FunctionInfo, + PyGICallableInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIRegisteredTypeInfo_Type, RegisteredTypeInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIStructInfo_Type, StructInfo, + PyGIRegisteredTypeInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIEnumInfo_Type, EnumInfo, + PyGIRegisteredTypeInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIObjectInfo_Type, ObjectInfo, + PyGIRegisteredTypeInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIInterfaceInfo_Type, InterfaceInfo, + PyGIRegisteredTypeInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIConstantInfo_Type, ConstantInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIValueInfo_Type, ValueInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIFieldInfo_Type, FieldInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIVFuncInfo_Type, VFuncInfo, + PyGIBaseInfo_Type); + _PyGI_REGISTER_TYPE (m, PyGIUnionInfo_Type, UnionInfo, + PyGIRegisteredTypeInfo_Type); + #undef _PyGI_REGISTER_TYPE } diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c index a470003..64b3f31 100644 --- a/gi/pygi-invoke.c +++ b/gi/pygi-invoke.c @@ -49,14 +49,14 @@ struct invocation_state GITypeInfo *return_type_info; GITypeTag return_type_tag; - GArgument **args; + GIArgument **args; gboolean *args_is_auxiliary; - GArgument *in_args; - GArgument *out_args; - GArgument *out_values; - GArgument *backup_args; - GArgument return_arg; + GIArgument *in_args; + GIArgument *out_args; + GIArgument *out_values; + GIArgument *backup_args; + GIArgument return_arg; PyObject *return_value; }; @@ -154,18 +154,14 @@ _prepare_invocation_state (struct invocation_state *state, if (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) { state->n_in_args += 1; - if (transfer == GI_TRANSFER_CONTAINER) { - state->n_backup_args += 1; - } + } + if (direction == GI_DIRECTION_INOUT) { + state->n_backup_args += 1; } if (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) { state->n_out_args += 1; } - if (direction == GI_DIRECTION_INOUT && transfer == GI_TRANSFER_NOTHING) { - state->n_backup_args += 1; - } - switch (arg_type_tag) { case GI_TYPE_TAG_ARRAY: { @@ -173,13 +169,16 @@ _prepare_invocation_state (struct invocation_state *state, length_arg_pos = g_type_info_get_array_length (state->arg_type_infos[i]); - if (state->is_method) - length_arg_pos--; // length_arg_pos refers to C args - if (length_arg_pos < 0) { break; } + /* For array lengths, we're going to delete the length argument; + * so remove the extra backup we just added above */ + if (direction == GI_DIRECTION_INOUT) { + state->n_backup_args -= 1; + } + g_assert (length_arg_pos < state->n_args); state->args_is_auxiliary[length_arg_pos] = TRUE; @@ -208,9 +207,6 @@ _prepare_invocation_state (struct invocation_state *state, gint length_arg_pos; length_arg_pos = g_type_info_get_array_length (state->return_type_info); - if (state->is_method) - length_arg_pos--; // length_arg_pos refers to C args - if (length_arg_pos >= 0) { g_assert (length_arg_pos < state->n_args); state->args_is_auxiliary[length_arg_pos] = TRUE; @@ -285,10 +281,10 @@ _prepare_invocation_state (struct invocation_state *state, } state->args = g_slice_alloc0 (sizeof (gpointer) * state->n_args); - state->in_args = g_slice_alloc0 (sizeof (GArgument) * state->n_in_args); - state->out_args = g_slice_alloc0 (sizeof (GArgument) * state->n_out_args); - state->out_values = g_slice_alloc0 (sizeof (GArgument) * state->n_out_args); - state->backup_args = g_slice_alloc0 (sizeof (GArgument) * state->n_backup_args); + state->in_args = g_slice_alloc0 (sizeof (GIArgument) * state->n_in_args); + state->out_args = g_slice_alloc0 (sizeof (GIArgument) * state->n_out_args); + state->out_values = g_slice_alloc0 (sizeof (GIArgument) * state->n_out_args); + state->backup_args = g_slice_alloc0 (sizeof (GIArgument) * state->n_backup_args); /* Bind args so we can use an unique index. */ { @@ -344,19 +340,15 @@ _prepare_invocation_state (struct invocation_state *state, } if (is_caller_allocates) { - gsize size; - /* if caller allocates only use one level of indirection */ state->out_args[out_args_pos].v_pointer = NULL; state->args[i] = &state->out_args[out_args_pos]; - - /* FIXME: Remove when bgo#622711 is fixed */ - if (g_registered_type_info_get_g_type (info) == G_TYPE_VALUE) - size = sizeof (GValue); - else - size = g_struct_info_get_size ( (GIStructInfo *) info); - - state->args[i]->v_pointer = g_malloc0 (size); + if (g_type_is_a (g_registered_type_info_get_g_type (info), G_TYPE_BOXED)) + state->args[i]->v_pointer = _pygi_boxed_alloc (info, NULL); + else { + gssize size = g_struct_info_get_size ( (GIStructInfo *) info); + state->args[i]->v_pointer = g_malloc0 (size); + } } else { state->out_args[out_args_pos].v_pointer = &state->out_values[out_args_pos]; state->out_values[out_args_pos].v_pointer = NULL; @@ -387,6 +379,7 @@ _prepare_invocation_state (struct invocation_state *state, GIBaseInfo *container_info; GIInfoType container_info_type; PyObject *py_arg; + gint check_val; container_info = g_base_info_get_container (function_info); container_info_type = g_base_info_get_type (container_info); @@ -394,6 +387,19 @@ _prepare_invocation_state (struct invocation_state *state, g_assert (py_args_pos < state->n_py_args); py_arg = PyTuple_GET_ITEM (py_args, py_args_pos); + /* In python 2 python takes care of checking the type + * of the self instance. In python 3 it does not + * so we have to check it here + */ + check_val = _pygi_g_type_interface_check_object(container_info, + py_arg); + if (check_val < 0) { + return FALSE; + } else if (!check_val) { + _PyGI_ERROR_PREFIX ("instance: "); + return FALSE; + } + switch (container_info_type) { case GI_INFO_TYPE_UNION: case GI_INFO_TYPE_STRUCT: @@ -487,60 +493,10 @@ _prepare_invocation_state (struct invocation_state *state, return FALSE; } - if (direction == GI_DIRECTION_INOUT && transfer == GI_TRANSFER_NOTHING) { + if (direction == GI_DIRECTION_INOUT) { /* We need to keep a copy of the argument to be able to release it later. */ g_assert (backup_args_pos < state->n_backup_args); state->backup_args[backup_args_pos] = *state->args[i]; - backup_args_pos += 1; - } else if (transfer == GI_TRANSFER_CONTAINER) { - /* We need to keep a copy of the items to be able to release them later. */ - switch (arg_type_tag) { - case GI_TYPE_TAG_ARRAY: - { - GArray *array; - gsize item_size; - GArray *new_array; - - array = state->args[i]->v_pointer; - - item_size = g_array_get_element_size (array); - - new_array = g_array_sized_new (FALSE, FALSE, item_size, array->len); - g_array_append_vals (new_array, array->data, array->len); - - g_assert (backup_args_pos < state->n_backup_args); - state->backup_args[backup_args_pos].v_pointer = new_array; - - break; - } - case GI_TYPE_TAG_GLIST: - g_assert (backup_args_pos < state->n_backup_args); - state->backup_args[backup_args_pos].v_pointer = g_list_copy (state->args[i]->v_pointer); - break; - case GI_TYPE_TAG_GSLIST: - g_assert (backup_args_pos < state->n_backup_args); - state->backup_args[backup_args_pos].v_pointer = g_slist_copy (state->args[i]->v_pointer); - break; - case GI_TYPE_TAG_GHASH: - { - GHashTable *hash_table; - GList *keys; - GList *values; - - hash_table = state->args[i]->v_pointer; - - keys = g_hash_table_get_keys (hash_table); - values = g_hash_table_get_values (hash_table); - - g_assert (backup_args_pos < state->n_backup_args); - state->backup_args[backup_args_pos].v_pointer = g_list_concat (keys, values); - - break; - } - default: - g_warn_if_reached(); - } - backup_args_pos += 1; } @@ -551,8 +507,6 @@ _prepare_invocation_state (struct invocation_state *state, array = state->args[i]->v_pointer; length_arg_pos = g_type_info_get_array_length (state->arg_type_infos[i]); - if (state->is_method) - length_arg_pos--; // length_arg_pos refers to C args if (length_arg_pos >= 0) { int len = 0; /* Set the auxiliary argument holding the length. */ @@ -639,6 +593,11 @@ _process_invocation_state (struct invocation_state *state, GIInfoType info_type; GITransfer transfer; + if (state->return_arg.v_pointer == NULL) { + PyErr_SetString (PyExc_TypeError, "constructor returned NULL"); + return FALSE; + } + g_assert (state->n_py_args > 0); py_type = (PyTypeObject *) PyTuple_GET_ITEM (py_args, 0); @@ -651,10 +610,6 @@ _process_invocation_state (struct invocation_state *state, switch (info_type) { case GI_INFO_TYPE_UNION: - /* TODO */ - PyErr_SetString (PyExc_NotImplementedError, "creating unions is not supported yet"); - g_base_info_unref (info); - return FALSE; case GI_INFO_TYPE_STRUCT: { GType type; @@ -662,24 +617,22 @@ _process_invocation_state (struct invocation_state *state, type = g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info); if (g_type_is_a (type, G_TYPE_BOXED)) { - if (state->return_arg.v_pointer == NULL) { - PyErr_SetString (PyExc_TypeError, "constructor returned NULL"); - break; - } g_warn_if_fail (transfer == GI_TRANSFER_EVERYTHING); state->return_value = _pygi_boxed_new (py_type, state->return_arg.v_pointer, transfer == GI_TRANSFER_EVERYTHING); + } else if (type == G_TYPE_NONE && g_struct_info_is_foreign (info)) { + state->return_value = + pygi_struct_foreign_convert_from_g_argument ( + state->return_type_info, state->return_arg.v_pointer); } else if (g_type_is_a (type, G_TYPE_POINTER) || type == G_TYPE_NONE) { - if (state->return_arg.v_pointer == NULL) { - PyErr_SetString (PyExc_TypeError, "constructor returned NULL"); - break; - } - if (transfer != GI_TRANSFER_NOTHING) - g_warning ("Transfer mode should be set to None for " + g_warning ("Return argument in %s returns a struct " + "with a transfer mode of \"full\" " + "Transfer mode should be set to None for " "struct types as there is no way to free " "them safely. Ignoring transfer mode " "to prevent a potential invalid free. " - "This may cause a leak in your application."); + "This may cause a leak in your application.", + g_base_info_get_name ( (GIBaseInfo *) function_info) ); state->return_value = _pygi_struct_new (py_type, state->return_arg.v_pointer, FALSE); } else { @@ -740,10 +693,8 @@ _process_invocation_state (struct invocation_state *state, /* Convert output arguments and release arguments. */ { - gsize backup_args_pos; gsize return_values_pos; - backup_args_pos = 0; return_values_pos = 0; if (state->n_return_values > 1) { @@ -795,6 +746,36 @@ _process_invocation_state (struct invocation_state *state, /* Convert the argument. */ PyObject *obj; + /* If we created it, deallocate when it goes out of scope + * otherwise it is unsafe to deallocate random structures + * we are given + */ + if (type_tag == GI_TYPE_TAG_INTERFACE) { + GIBaseInfo *info; + GIInfoType info_type; + + info = g_type_info_get_interface (state->arg_type_infos[i]); + g_assert (info != NULL); + info_type = g_base_info_get_type (info); + + if ( (info_type == GI_INFO_TYPE_STRUCT) && + !g_struct_info_is_foreign((GIStructInfo *) info) ) { + if (g_arg_info_is_caller_allocates (state->arg_infos[i])) { + transfer = GI_TRANSFER_EVERYTHING; + } else if (transfer == GI_TRANSFER_EVERYTHING) { + transfer = GI_TRANSFER_NOTHING; + g_warning ("Out argument %ld in %s returns a struct " + "with a transfer mode of \"full\". " + "Transfer mode should be set to \"none\" for " + "struct type returns as there is no way to free " + "them safely. Ignoring transfer mode " + "to prevent a potential invalid free. " + "This may cause a leak in your application.", + i, g_base_info_get_name ( (GIBaseInfo *) function_info) ); + } + } + } + obj = _pygi_argument_to_object (state->args[i], state->arg_type_infos[i], transfer); if (obj == NULL) { /* TODO: release arguments. */ @@ -814,83 +795,9 @@ _process_invocation_state (struct invocation_state *state, return_values_pos += 1; } - /* Release the argument. */ - - if ( (direction == GI_DIRECTION_IN || direction == GI_DIRECTION_INOUT) - && transfer == GI_TRANSFER_CONTAINER) { - /* Release the items we kept in another container. */ - switch (type_tag) { - case GI_TYPE_TAG_ARRAY: - case GI_TYPE_TAG_GLIST: - case GI_TYPE_TAG_GSLIST: - g_assert (backup_args_pos < state->n_backup_args); - _pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i], - transfer, GI_DIRECTION_IN); - break; - case GI_TYPE_TAG_GHASH: - { - GITypeInfo *key_type_info; - GITypeInfo *value_type_info; - GList *item; - gsize length; - gsize j; - - key_type_info = g_type_info_get_param_type (state->arg_type_infos[i], 0); - value_type_info = g_type_info_get_param_type (state->arg_type_infos[i], 1); - - g_assert (backup_args_pos < state->n_backup_args); - item = state->backup_args[backup_args_pos].v_pointer; - - length = g_list_length (item) / 2; - - for (j = 0; j < length; j++, item = g_list_next (item)) { - _pygi_argument_release ( (GArgument *) &item->data, key_type_info, - GI_TRANSFER_NOTHING, GI_DIRECTION_IN); - } - - for (j = 0; j < length; j++, item = g_list_next (item)) { - _pygi_argument_release ( (GArgument *) &item->data, value_type_info, - GI_TRANSFER_NOTHING, GI_DIRECTION_IN); - } - - g_list_free (state->backup_args[backup_args_pos].v_pointer); - - break; - } - default: - g_warn_if_reached(); - } - - if (direction == GI_DIRECTION_INOUT) { - /* Release the output argument. */ - _pygi_argument_release (state->args[i], state->arg_type_infos[i], GI_TRANSFER_CONTAINER, - GI_DIRECTION_OUT); - } - - backup_args_pos += 1; - } else if (direction == GI_DIRECTION_INOUT) { - if (transfer == GI_TRANSFER_NOTHING) { - g_assert (backup_args_pos < state->n_backup_args); - _pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i], - GI_TRANSFER_NOTHING, GI_DIRECTION_IN); - backup_args_pos += 1; - } - - _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer, - GI_DIRECTION_OUT); - } else { - _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer, direction); - } - - if (type_tag == GI_TYPE_TAG_ARRAY - && (direction != GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)) { - /* We created a #GArray and it has not been released above, so free it. */ - state->args[i]->v_pointer = g_array_free (state->args[i]->v_pointer, FALSE); - } } g_assert (state->n_return_values <= 1 || return_values_pos == state->n_return_values); - g_assert (backup_args_pos == state->n_backup_args); } return TRUE; @@ -900,6 +807,7 @@ static void _free_invocation_state (struct invocation_state *state) { gsize i; + gsize backup_args_pos; if (state->return_type_info != NULL) { g_base_info_unref ( (GIBaseInfo *) state->return_type_info); @@ -910,29 +818,42 @@ _free_invocation_state (struct invocation_state *state) _pygi_invoke_closure_free (state->closure); } + /* release all arguments. */ + backup_args_pos = 0; for (i = 0; i < state->n_args; i++) { - /* check for caller-allocated values we need to free */ - if (g_arg_info_is_caller_allocates (state->arg_infos[i])) { - GIBaseInfo *info; - GIInfoType info_type; + if (state->args_is_auxiliary[i]) { + /* Auxiliary arguments are not released. */ + continue; + } - info = g_type_info_get_interface (state->arg_type_infos[i]); - g_assert (info != NULL); - info_type = g_base_info_get_type (info); + if (state->args != NULL + && state->args[i] != NULL + && state->arg_infos[i] != NULL + && state->arg_type_infos[i] != NULL) { + GIDirection direction; + GITypeTag type_tag; + GITransfer transfer; - /* caller-allocates applies only to structs right now - * the GI scanner is overzealous when marking parameters - * as caller-allocates, so we only free if this was a struct - */ - if (info_type == GI_INFO_TYPE_STRUCT) { - /* special case GValues so we make sure to unset them */ - if (g_registered_type_info_get_g_type ( (GIRegisteredTypeInfo *) info) == G_TYPE_VALUE) { - g_value_unset ( (GValue *) state->args[i]); - } + direction = g_arg_info_get_direction (state->arg_infos[i]); + transfer = g_arg_info_get_ownership_transfer (state->arg_infos[i]); + + type_tag = g_type_info_get_tag (state->arg_type_infos[i]); + + /* Release the argument. */ + if (direction == GI_DIRECTION_INOUT) { + _pygi_argument_release (&state->backup_args[backup_args_pos], state->arg_type_infos[i], + transfer, GI_DIRECTION_IN); + backup_args_pos += 1; + } + _pygi_argument_release (state->args[i], state->arg_type_infos[i], transfer, direction); - g_free (state->args[i]); + if (type_tag == GI_TYPE_TAG_ARRAY + && (direction != GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)) { + /* We created a #GArray and it has not been released above, so free it. */ + state->args[i]->v_pointer = g_array_free (state->args[i]->v_pointer, FALSE); } + } if (state->arg_type_infos[i] != NULL) @@ -940,37 +861,30 @@ _free_invocation_state (struct invocation_state *state) if (state->arg_infos[i] != NULL) g_base_info_unref ( (GIBaseInfo *) state->arg_infos[i]); } + g_assert (backup_args_pos == state->n_backup_args); - if (state->arg_infos != NULL) { - g_slice_free1 (sizeof (gpointer) * state->n_args, state->arg_infos); - } - - if (state->arg_type_infos != NULL) { - g_slice_free1 (sizeof (gpointer) * state->n_args, state->arg_type_infos); - } + g_slice_free1 (sizeof (gpointer) * state->n_args, state->arg_infos); + g_slice_free1 (sizeof (gpointer) * state->n_args, state->arg_type_infos); + g_slice_free1 (sizeof (gboolean) * state->n_args, state->args_is_auxiliary); if (state->args != NULL) { g_slice_free1 (sizeof (gpointer) * state->n_args, state->args); } - if (state->args_is_auxiliary != NULL) { - g_slice_free1 (sizeof (gboolean) * state->n_args, state->args_is_auxiliary); - } - if (state->in_args != NULL) { - g_slice_free1 (sizeof (GArgument) * state->n_in_args, state->in_args); + g_slice_free1 (sizeof (GIArgument) * state->n_in_args, state->in_args); } if (state->out_args != NULL) { - g_slice_free1 (sizeof (GArgument) * state->n_out_args, state->out_args); + g_slice_free1 (sizeof (GIArgument) * state->n_out_args, state->out_args); } if (state->out_values != NULL) { - g_slice_free1 (sizeof (GArgument) * state->n_out_args, state->out_values); + g_slice_free1 (sizeof (GIArgument) * state->n_out_args, state->out_values); } if (state->backup_args != NULL) { - g_slice_free1 (sizeof (GArgument) * state->n_backup_args, state->backup_args); + g_slice_free1 (sizeof (GIArgument) * state->n_backup_args, state->backup_args); } if (PyErr_Occurred()) { @@ -1001,6 +915,7 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self, PyObject *py_args) return NULL; } + _free_invocation_state (&state); return state.return_value; } diff --git a/gi/pygi-private.h b/gi/pygi-private.h index 0ff5df7..3a14bc3 100644 --- a/gi/pygi-private.h +++ b/gi/pygi-private.h @@ -28,8 +28,30 @@ #include "pygi-closure.h" #include "pygi-callbacks.h" #include "pygi-invoke.h" +#include "pygi-property.h" G_BEGIN_DECLS +#if PY_VERSION_HEX >= 0x03000000 + +#define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \ + PyObject *py_error_prefix; \ + py_error_prefix = PyUnicode_FromFormat(format, ## __VA_ARGS__); \ + if (py_error_prefix != NULL) { \ + PyObject *py_error_type, *py_error_value, *py_error_traceback; \ + PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \ + if (PyUnicode_Check(py_error_value)) { \ + PyObject *new; \ + new = PyUnicode_Concat(py_error_prefix, py_error_value); \ + Py_DECREF(py_error_value); \ + if (new != NULL) { \ + py_error_value = new; \ + } \ + } \ + PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \ + } \ +} G_STMT_END + +#else #define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \ PyObject *py_error_prefix; \ @@ -47,6 +69,8 @@ G_BEGIN_DECLS } \ } G_STMT_END +#endif + /* Redefine g_array_index because we want it to return the i-th element, casted * to the type t, of the array a, and not the i-th element of the array a * casted to the type t. */ diff --git a/gi/pygi-property.c b/gi/pygi-property.c new file mode 100644 index 0000000..7b6a508 --- /dev/null +++ b/gi/pygi-property.c @@ -0,0 +1,345 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2010 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "pygi-private.h" + +#include + +/* Copied from glib */ +static void +canonicalize_key (gchar *key) +{ + gchar *p; + + for (p = key; *p != 0; p++) + { + gchar c = *p; + + if (c != '-' && + (c < '0' || c > '9') && + (c < 'A' || c > 'Z') && + (c < 'a' || c > 'z')) + *p = '-'; + } +} + +static GIPropertyInfo * +_pygi_lookup_property_from_g_type (GType g_type, const gchar *attr_name) +{ + GIRepository *repository; + GIBaseInfo *info; + gssize n_infos; + gssize i; + GType parent; + + repository = g_irepository_get_default(); + info = g_irepository_find_by_gtype (repository, g_type); + if (info == NULL) { + return NULL; + } + + n_infos = g_object_info_get_n_properties ( (GIObjectInfo *) info); + for (i = 0; i < n_infos; i++) { + GIPropertyInfo *property_info; + + property_info = g_object_info_get_property ( (GIObjectInfo *) info, i); + g_assert (info != NULL); + + if (strcmp (attr_name, g_base_info_get_name (property_info)) == 0) { + g_base_info_unref (info); + return property_info; + } + + g_base_info_unref (property_info); + } + + g_base_info_unref (info); + + parent = g_type_parent (g_type); + if (parent > 0) + return _pygi_lookup_property_from_g_type (parent, attr_name); + + return NULL; +} + +PyObject * +pygi_get_property_value_real (PyGObject *instance, + const gchar *attr_name) +{ + GType g_type; + GIPropertyInfo *property_info = NULL; + char *property_name = g_strdup (attr_name); + GParamSpec *pspec = NULL; + GValue value = { 0, }; + GIArgument arg = { 0, }; + PyObject *py_value = NULL; + GITypeInfo *type_info = NULL; + GITransfer transfer; + + canonicalize_key (property_name); + + g_type = pyg_type_from_object ((PyObject *)instance); + property_info = _pygi_lookup_property_from_g_type (g_type, property_name); + + if (property_info == NULL) + goto out; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (instance->obj), + attr_name); + if (pspec == NULL) + goto out; + + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_object_get_property (instance->obj, attr_name, &value); + + type_info = g_property_info_get_type (property_info); + transfer = g_property_info_get_ownership_transfer (property_info); + + GITypeTag type_tag = g_type_info_get_tag (type_info); + switch (type_tag) { + case GI_TYPE_TAG_BOOLEAN: + arg.v_boolean = g_value_get_boolean (&value); + break; + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_INT64: + arg.v_int = g_value_get_int (&value); + break; + case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_UINT64: + arg.v_uint = g_value_get_uint (&value); + break; + case GI_TYPE_TAG_FLOAT: + arg.v_float = g_value_get_float (&value); + break; + case GI_TYPE_TAG_DOUBLE: + arg.v_double = g_value_get_double (&value); + break; + case GI_TYPE_TAG_GTYPE: + arg.v_size = g_value_get_uint (&value); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + arg.v_string = g_value_dup_string (&value); + break; + case GI_TYPE_TAG_INTERFACE: + { + GIBaseInfo *info; + GIInfoType info_type; + GType type; + + info = g_type_info_get_interface (type_info); + type = g_registered_type_info_get_g_type (info); + info_type = g_base_info_get_type (info); + + switch (info_type) { + case GI_INFO_TYPE_ENUM: + arg.v_int32 = g_value_get_enum (&value); + break; + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_OBJECT: + arg.v_pointer = g_value_get_object (&value); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + case GI_INFO_TYPE_UNION: + + if (g_type_is_a (type, G_TYPE_BOXED)) { + arg.v_pointer = g_value_get_boxed (&value); + } else if (g_type_is_a (type, G_TYPE_POINTER)) { + arg.v_pointer = g_value_get_pointer (&value); + } else { + PyErr_Format (PyExc_NotImplementedError, + "Retrieving properties of type '%s' is not implemented", + g_type_name (type)); + } + break; + default: + PyErr_Format (PyExc_NotImplementedError, + "Retrieving properties of type '%s' is not implemented", + g_type_name (type)); + goto out; + } + break; + } + case GI_TYPE_TAG_GHASH: + arg.v_pointer = g_value_get_boxed (&value); + break; + case GI_TYPE_TAG_GLIST: + arg.v_pointer = g_value_get_pointer (&value); + break; + default: + PyErr_Format (PyExc_NotImplementedError, + "Retrieving properties of type %s is not implemented", + g_type_tag_to_string (g_type_info_get_tag (type_info))); + goto out; + } + + py_value = _pygi_argument_to_object (&arg, type_info, transfer); + +out: + g_free (property_name); + if (property_info != NULL) + g_base_info_unref (property_info); + if (type_info != NULL) + g_base_info_unref (type_info); + + return py_value; +} + +gint +pygi_set_property_value_real (PyGObject *instance, + const gchar *attr_name, + PyObject *py_value) +{ + GType g_type; + GIPropertyInfo *property_info = NULL; + char *property_name = g_strdup (attr_name); + GITypeInfo *type_info = NULL; + GITypeTag type_tag; + GITransfer transfer; + GValue value = { 0, }; + GIArgument arg = { 0, }; + GParamSpec *pspec = NULL; + gint ret_value = -1; + + canonicalize_key (property_name); + + g_type = pyg_type_from_object ((PyObject *)instance); + property_info = _pygi_lookup_property_from_g_type (g_type, property_name); + + if (property_info == NULL) + goto out; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (instance->obj), + attr_name); + if (pspec == NULL) + goto out; + + if (! (pspec->flags & G_PARAM_WRITABLE)) + goto out; + + type_info = g_property_info_get_type (property_info); + transfer = g_property_info_get_ownership_transfer (property_info); + arg = _pygi_argument_from_object (py_value, type_info, transfer); + + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + + // FIXME: Lots of types still unhandled + type_tag = g_type_info_get_tag (type_info); + switch (type_tag) { + case GI_TYPE_TAG_INTERFACE: + { + GIBaseInfo *info; + GIInfoType info_type; + GType type; + + info = g_type_info_get_interface (type_info); + type = g_registered_type_info_get_g_type (info); + info_type = g_base_info_get_type (info); + + switch (info_type) { + case GI_INFO_TYPE_ENUM: + g_value_set_enum (&value, arg.v_int32); + break; + case GI_INFO_TYPE_INTERFACE: + case GI_INFO_TYPE_OBJECT: + g_value_set_object (&value, arg.v_pointer); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + case GI_INFO_TYPE_UNION: + if (g_type_is_a (type, G_TYPE_BOXED)) { + g_value_set_boxed (&value, arg.v_pointer); + } else { + PyErr_Format (PyExc_NotImplementedError, + "Setting properties of type '%s' is not implemented", + g_type_name (type)); + } + break; + default: + PyErr_Format (PyExc_NotImplementedError, + "Setting properties of type '%s' is not implemented", + g_type_name (type)); + goto out; + } + break; + } + case GI_TYPE_TAG_BOOLEAN: + g_value_set_boolean (&value, arg.v_boolean); + break; + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_INT64: + g_value_set_int (&value, arg.v_int); + break; + case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_UINT16: + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_UINT64: + g_value_set_uint (&value, arg.v_uint); + break; + case GI_TYPE_TAG_FLOAT: + g_value_set_float (&value, arg.v_float); + break; + case GI_TYPE_TAG_DOUBLE: + g_value_set_double (&value, arg.v_double); + break; + case GI_TYPE_TAG_GTYPE: + g_value_set_uint (&value, arg.v_size); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + g_value_set_string (&value, arg.v_string); + break; + case GI_TYPE_TAG_GHASH: + g_value_set_boxed (&value, arg.v_pointer); + break; + case GI_TYPE_TAG_GLIST: + g_value_set_pointer (&value, arg.v_pointer); + break; + default: + PyErr_Format (PyExc_NotImplementedError, + "Setting properties of type %s is not implemented", + g_type_tag_to_string (g_type_info_get_tag (type_info))); + goto out; + } + + g_object_set_property (instance->obj, attr_name, &value); + + ret_value = 0; + +out: + g_free (property_name); + if (property_info != NULL) + g_base_info_unref (property_info); + if (type_info != NULL) + g_base_info_unref (type_info); + + return ret_value; +} + diff --git a/gi/pygi-property.h b/gi/pygi-property.h new file mode 100644 index 0000000..31d0e42 --- /dev/null +++ b/gi/pygi-property.h @@ -0,0 +1,39 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* + * Copyright (c) 2010 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef __PYGI_PROPERTY_H__ +#define __PYGI_PROPERTY_H__ + +#include +#include + +#include "pygi.h" + +PyObject *pygi_get_property_value_real (PyGObject *instance, + const gchar *attr_name); + +gint pygi_set_property_value_real (PyGObject *instance, + const gchar *attr_name, + PyObject *py_value); + +#endif /* __PYGI_PROPERTY_H__ */ diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c index 783b4aa..9b22eae 100644 --- a/gi/pygi-repository.c +++ b/gi/pygi-repository.c @@ -23,41 +23,42 @@ #include "pygi-private.h" +#include + PyObject *PyGIRepositoryError; static PyMethodDef _PyGIRepository_methods[]; -PyTypeObject PyGIRepository_Type = { - PyObject_HEAD_INIT (NULL) - 0, - "gi.Repository", /* tp_name */ - sizeof (PyGIRepository), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) NULL, /* tp_dealloc */ - (printfunc) NULL, /* tp_print */ - (getattrfunc) NULL, /* tp_getattr */ - (setattrfunc) NULL, /* tp_setattr */ - (cmpfunc) NULL, /* tp_compare */ - (reprfunc) NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - (hashfunc) NULL, /* tp_hash */ - (ternaryfunc) NULL, /* tp_call */ - (reprfunc) NULL, /* tp_str */ - (getattrofunc) NULL, /* tp_getattro */ - (setattrofunc) NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - NULL, /* tp_doc */ - (traverseproc) NULL, /* tp_traverse */ - (inquiry) NULL, /* tp_clear */ - (richcmpfunc) NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) NULL, /* tp_iter */ - (iternextfunc) NULL, /* tp_iternext */ - _PyGIRepository_methods, /* tp_methods */ -}; +PYGLIB_DEFINE_TYPE("gi.Repository", PyGIRepository_Type, PyGIRepository); + +static PyObject * +_wrap_g_irepository_enumerate_versions (PyGIRepository *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "namespace", NULL }; + const char *namespace_; + GList *versions, *item; + PyObject *ret = NULL; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s:Repository.enumerate_versions", + kwlist, &namespace_)) { + return NULL; + } + + versions = g_irepository_enumerate_versions (self->repository, namespace_); + ret = PyList_New(0); + for (item = versions; item; item = item->next) { + char *version = item->data; + PyObject *py_version = PYGLIB_PyUnicode_FromString (version); + PyList_Append(ret, py_version); + Py_DECREF(py_version); + g_free (version); + } + g_list_free(versions); + + return ret; +} static PyObject * _wrap_g_irepository_get_default (PyObject *self) @@ -91,7 +92,7 @@ _wrap_g_irepository_require (PyGIRepository *self, GTypelib *typelib; GError *error; - if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s|sO:Repository.require", + if (!PyArg_ParseTupleAndKeywords (args, kwargs, "s|zO:Repository.require", kwlist, &namespace_, &version, &lazy)) { return NULL; } @@ -207,25 +208,55 @@ _wrap_g_irepository_get_typelib_path (PyGIRepository *self, return NULL; } - return PyString_FromString (typelib_path); + return PYGLIB_PyBytes_FromString (typelib_path); +} + +static PyObject * +_wrap_g_irepository_get_version (PyGIRepository *self, + PyObject *args, + PyObject *kwargs) +{ + static char *kwlist[] = { "namespace", NULL }; + const char *namespace_; + const gchar *version; + + if (!PyArg_ParseTupleAndKeywords (args, kwargs, + "s:Repository.get_version", kwlist, &namespace_)) { + return NULL; + } + + version = g_irepository_get_version (self->repository, namespace_); + if (version == NULL) { + PyErr_Format (PyExc_RuntimeError, "Namespace '%s' not loaded", namespace_); + return NULL; + } + + return PYGLIB_PyUnicode_FromString (version); } static PyMethodDef _PyGIRepository_methods[] = { + { "enumerate_versions", (PyCFunction) _wrap_g_irepository_enumerate_versions, METH_VARARGS | METH_KEYWORDS }, { "get_default", (PyCFunction) _wrap_g_irepository_get_default, METH_STATIC | METH_NOARGS }, { "require", (PyCFunction) _wrap_g_irepository_require, METH_VARARGS | METH_KEYWORDS }, { "get_infos", (PyCFunction) _wrap_g_irepository_get_infos, METH_VARARGS | METH_KEYWORDS }, { "find_by_name", (PyCFunction) _wrap_g_irepository_find_by_name, METH_VARARGS | METH_KEYWORDS }, { "get_typelib_path", (PyCFunction) _wrap_g_irepository_get_typelib_path, METH_VARARGS | METH_KEYWORDS }, + { "get_version", (PyCFunction) _wrap_g_irepository_get_version, METH_VARARGS | METH_KEYWORDS }, { NULL, NULL, 0 } }; void _pygi_repository_register_types (PyObject *m) { - PyGIRepository_Type.ob_type = &PyType_Type; + Py_TYPE(&PyGIRepository_Type) = &PyType_Type; + + PyGIRepository_Type.tp_flags = Py_TPFLAGS_DEFAULT; + PyGIRepository_Type.tp_methods = _PyGIRepository_methods; + if (PyType_Ready (&PyGIRepository_Type)) { return; } + if (PyModule_AddObject (m, "Repository", (PyObject *) &PyGIRepository_Type)) { return; } diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c index 2f1ce42..c2e1f4d 100644 --- a/gi/pygi-struct.c +++ b/gi/pygi-struct.c @@ -25,19 +25,28 @@ #include #include +#include static void _struct_dealloc (PyGIStruct *self) { + GIBaseInfo *info = _pygi_object_get_gi_info ( + (PyObject *) self, + &PyGIStructInfo_Type); + PyObject_GC_UnTrack ( (PyObject *) self); PyObject_ClearWeakRefs ( (PyObject *) self); - if (self->free_on_dealloc) { + if (info != NULL && g_struct_info_is_foreign ( (GIStructInfo *) info)) { + pygi_struct_foreign_release (info, ( (PyGPointer *) self)->pointer); + } else if (self->free_on_dealloc) { g_free ( ( (PyGPointer *) self)->pointer); } - ( (PyGPointer *) self)->ob_type->tp_free ( (PyObject *) self); + g_base_info_unref (info); + + Py_TYPE( (PyGPointer *) self )->tp_free ( (PyObject *) self); } static PyObject * @@ -48,7 +57,6 @@ _struct_new (PyTypeObject *type, static char *kwlist[] = { NULL }; GIBaseInfo *info; - gboolean is_simple; gsize size; gpointer pointer; PyObject *self = NULL; @@ -92,41 +100,7 @@ _struct_init (PyObject *self, return 0; } - -PyTypeObject PyGIStruct_Type = { - PyObject_HEAD_INIT (NULL) - 0, - "gi.Struct", /* tp_name */ - sizeof (PyGIStruct), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) _struct_dealloc, /* tp_dealloc */ - (printfunc) NULL, /* tp_print */ - (getattrfunc) NULL, /* tp_getattr */ - (setattrfunc) NULL, /* tp_setattr */ - (cmpfunc) NULL, /* tp_compare */ - (reprfunc) NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - (hashfunc) NULL, /* tp_hash */ - (ternaryfunc) NULL, /* tp_call */ - (reprfunc) NULL, /* tp_str */ - (getattrofunc) NULL, /* tp_getattro */ - (setattrofunc) NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* tp_doc */ - (traverseproc) NULL, /* tp_traverse */ - (inquiry) NULL, /* tp_clear */ - (richcmpfunc) NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) NULL, /* tp_iter */ - (iternextfunc) NULL, /* tp_iternext */ - NULL, /* tp_methods */ - NULL, /* tp_members */ - NULL, /* tp_getset */ - (PyTypeObject *) NULL, /* tp_base */ -}; +PYGLIB_DEFINE_TYPE("gi.Struct", PyGIStruct_Type, PyGIStruct); PyObject * _pygi_struct_new (PyTypeObject *type, @@ -158,10 +132,13 @@ _pygi_struct_new (PyTypeObject *type, void _pygi_struct_register_types (PyObject *m) { - PyGIStruct_Type.ob_type = &PyType_Type; + Py_TYPE(&PyGIStruct_Type) = &PyType_Type; PyGIStruct_Type.tp_base = &PyGPointer_Type; PyGIStruct_Type.tp_new = (newfunc) _struct_new; PyGIStruct_Type.tp_init = (initproc) _struct_init; + PyGIStruct_Type.tp_dealloc = (destructor) _struct_dealloc; + PyGIStruct_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + if (PyType_Ready (&PyGIStruct_Type)) return; if (PyModule_AddObject (m, "Struct", (PyObject *) &PyGIStruct_Type)) diff --git a/gi/pygi-type.c b/gi/pygi-type.c index bd9804e..129ea98 100644 --- a/gi/pygi-type.c +++ b/gi/pygi-type.c @@ -25,17 +25,13 @@ PyObject * -_pygi_type_import_by_gi_info (GIBaseInfo *info) +_pygi_type_import_by_name (const char *namespace_, + const char *name) { - const gchar *namespace_; - const gchar *name; gchar *module_name; PyObject *py_module; PyObject *py_object; - namespace_ = g_base_info_get_namespace (info); - name = g_base_info_get_name (info); - module_name = g_strconcat ("gi.repository.", namespace_, NULL); py_module = PyImport_ImportModule (module_name); @@ -73,6 +69,13 @@ pygi_type_import_by_g_type_real (GType g_type) return type; } +PyObject * +_pygi_type_import_by_gi_info (GIBaseInfo *info) +{ + return _pygi_type_import_by_name (g_base_info_get_namespace (info), + g_base_info_get_name (info)); +} + PyObject * _pygi_type_get_from_g_type (GType g_type) { diff --git a/gi/pygi-type.h b/gi/pygi-type.h index 16d5bdc..bb43d19 100644 --- a/gi/pygi-type.h +++ b/gi/pygi-type.h @@ -33,6 +33,8 @@ PyObject *pygi_type_import_by_g_type_real (GType g_type); /* Private */ +PyObject *_pygi_type_import_by_name (const char *namespace_, const char *name); + PyObject *_pygi_type_import_by_gi_info (GIBaseInfo *info); PyObject *_pygi_type_get_from_g_type (GType g_type); diff --git a/gi/pygi.h b/gi/pygi.h index 0a8cbf5..d1eaf05 100644 --- a/gi/pygi.h +++ b/gi/pygi.h @@ -22,6 +22,7 @@ #ifndef __PYGI_H__ #define __PYGI_H__ +#define NO_IMPORT_PYGOBJECT #include #include @@ -51,23 +52,27 @@ typedef struct { gsize size; } PyGIBoxed; -typedef PyObject * (*PyGIArgOverrideToGArgumentFunc) (PyObject *value, +typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value, GITypeInfo *type_info, GITransfer transfer, - GArgument *arg); -typedef PyObject * (*PyGIArgOverrideFromGArgumentFunc) (GITypeInfo *type_info, - GArgument *arg); -typedef PyObject * (*PyGIArgOverrideReleaseGArgumentFunc) (GITransfer transfer, - GITypeInfo *type_info, - GArgument *arg); + GIArgument *arg); +typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GITypeInfo *type_info, + GIArgument *arg); +typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info, + gpointer struct_); struct PyGI_API { PyObject* (*type_import_by_g_type) (GType g_type); + PyObject* (*get_property_value) (PyGObject *instance, + const gchar *attr_name); + gint (*set_property_value) (PyGObject *instance, + const gchar *attr_name, + PyObject *value); void (*register_foreign_struct) (const char* namespace_, const char* name, - PyGIArgOverrideToGArgumentFunc to_func, - PyGIArgOverrideFromGArgumentFunc from_func, - PyGIArgOverrideReleaseGArgumentFunc release_func); + PyGIArgOverrideToGIArgumentFunc to_func, + PyGIArgOverrideFromGIArgumentFunc from_func, + PyGIArgOverrideReleaseFunc release_func); }; static struct PyGI_API *PyGI_API = NULL; @@ -96,12 +101,33 @@ pygi_type_import_by_g_type (GType g_type) return PyGI_API->type_import_by_g_type(g_type); } +static inline PyObject * +pygi_get_property_value (PyGObject *instance, + const gchar *attr_name) +{ + if (_pygi_import() < 0) { + return NULL; + } + return PyGI_API->get_property_value(instance, attr_name); +} + +static inline gint +pygi_set_property_value (PyGObject *instance, + const gchar *attr_name, + PyObject *value) +{ + if (_pygi_import() < 0) { + return -1; + } + return PyGI_API->set_property_value(instance, attr_name, value); +} + static inline PyObject * pygi_register_foreign_struct (const char* namespace_, const char* name, - PyGIArgOverrideToGArgumentFunc to_func, - PyGIArgOverrideFromGArgumentFunc from_func, - PyGIArgOverrideReleaseGArgumentFunc release_func) + PyGIArgOverrideToGIArgumentFunc to_func, + PyGIArgOverrideFromGIArgumentFunc from_func, + PyGIArgOverrideReleaseFunc release_func) { if (_pygi_import() < 0) { return NULL; @@ -122,6 +148,21 @@ pygi_type_import_by_g_type (GType g_type) return NULL; } +static inline PyObject * +pygi_get_property_value (PyGObject *instance, + const gchar *attr_name) +{ + return -1; +} + +static inline gint +pygi_set_property_value (PyGObject *instance, + const gchar *attr_name, + PyObject *value) +{ + return -1; +} + #endif /* ENABLE_INTROSPECTION */ #endif /* __PYGI_H__ */ diff --git a/gi/repository/Makefile.in b/gi/repository/Makefile.in index 3252c9d..7b36c15 100644 --- a/gi/repository/Makefile.in +++ b/gi/repository/Makefile.in @@ -115,6 +115,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/gi/types.py b/gi/types.py index 8ac9cab..0a8768c 100644 --- a/gi/types.py +++ b/gi/types.py @@ -50,7 +50,7 @@ def Constructor(info): def constructor(cls, *args): cls_name = info.get_container().get_name() if cls.__name__ != cls_name: - raise TypeError, '%s constructor cannot be used to create instances of a subclass' % cls_name + raise TypeError('%s constructor cannot be used to create instances of a subclass' % cls_name) return info.invoke(cls, *args) constructor.__info__ = info @@ -105,10 +105,14 @@ class MetaClassHelper(object): 'the method do_%s()' % (base.__info__.get_namespace(), base.__info__.get_name(), vfunc_info.get_name())) - elif vfunc is not None and not \ - is_function_in_classes(vfunc.im_func, cls.__bases__): - hook_up_vfunc_implementation(vfunc_info, cls.__gtype__, - vfunc) + elif vfunc is not None: + function = vfunc + if sys.version_info < (3, 0): + function = vfunc.im_func + + if not is_function_in_classes(function, cls.__bases__): + hook_up_vfunc_implementation(vfunc_info, cls.__gtype__, + vfunc) def is_function_in_classes(function, classes): for klass in classes: @@ -161,6 +165,7 @@ class StructMeta(type, MetaClassHelper): def override(type_): g_type = type_.__info__.get_g_type() + assert g_type != gobject.TYPE_NONE if g_type != gobject.TYPE_INVALID: g_type.pytype = type_ return type_ diff --git a/gio/Makefile.in b/gio/Makefile.in index f7bf2eb..5315074 100644 --- a/gio/Makefile.in +++ b/gio/Makefile.in @@ -169,6 +169,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/gio/gappinfo.override b/gio/gappinfo.override index 414769b..7f09ce8 100644 --- a/gio/gappinfo.override +++ b/gio/gappinfo.override @@ -106,6 +106,11 @@ _wrap_g_app_info_launch_uris(PyGObject *self, PyObject *args, PyObject *kwargs) ret = g_app_info_launch_uris(G_APP_INFO(self->obj), file_list, ctx, &error); + /* in python 3 the C strings are not internal to the Unicode string object + * so we now strdup when adding element to the list and must free them here + */ + g_list_foreach (file_list, + (GFunc) g_free, NULL); g_list_free(file_list); if (pyg_error_check(&error)) diff --git a/gio/gfile.override b/gio/gfile.override index 71e2d98..b50130c 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -1155,7 +1155,7 @@ _wrap_g_file_append_to_async(PyGObject *self, PyObject *args, PyObject *kwargs) "O|OiOO:File.append_to_async", kwlist, ¬ify->callback, - &flags, &io_priority, + &py_flags, &io_priority, &pycancellable, ¬ify->data)) goto error; @@ -1203,7 +1203,7 @@ _wrap_g_file_create_async(PyGObject *self, PyObject *args, PyObject *kwargs) "O|OiOO:File.create_async", kwlist, ¬ify->callback, - &flags, &io_priority, + &py_flags, &io_priority, &pycancellable, ¬ify->data)) goto error; @@ -1253,7 +1253,7 @@ _wrap_g_file_create_readwrite_async(PyGObject *self, "O|OiOO:File.create_readwrite_async", kwlist, ¬ify->callback, - &flags, &io_priority, + &py_flags, &io_priority, &pycancellable, ¬ify->data)) goto error; @@ -1405,7 +1405,7 @@ _wrap_g_file_replace_async(PyGObject *self, PyObject *args, PyObject *kwargs) kwlist, ¬ify->callback, &etag, &py_backup, - &flags, &io_priority, + &py_flags, &io_priority, &pycancellable, ¬ify->data)) goto error; diff --git a/gio/gio.override b/gio/gio.override index 6d001b9..7fdcb1c 100644 --- a/gio/gio.override +++ b/gio/gio.override @@ -141,7 +141,7 @@ pygio_notify_allocate_buffer(PyGIONotify *notify, gsize buffer_size) if (buffer_size > 0) { notify->buffer = g_slice_alloc(buffer_size); if (!notify->buffer) { - PyErr_Format(PyExc_MemoryError, "failed to allocate %d bytes", buffer_size); + PyErr_Format(PyExc_MemoryError, "failed to allocate %" G_GSIZE_FORMAT " bytes", buffer_size); return FALSE; } @@ -330,7 +330,12 @@ _wrap_g_content_type_guess(PyGObject *self, PyObject *args, PyObject *kwargs) { char *kwlist[] = {"filename", "data", "want_uncertain", NULL}; char *filename = NULL, *data = NULL, *type; +#ifdef PY_SSIZE_T_CLEAN + Py_ssize_t data_size = 0; +#else int data_size = 0; +#endif + gboolean result_uncertain, want_uncertain = FALSE; PyObject *ret; diff --git a/gio/giomodule.c b/gio/giomodule.c index 409aeef..a9ddd38 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -39,167 +40,169 @@ void pygio_add_constants(PyObject *module, const gchar *strip_prefix); extern PyMethodDef pygio_functions[]; -DL_EXPORT(void) -init_gio(void) +PYGLIB_INIT_FUNCTION(_gio, "gio._gio", pygio_functions) { - PyObject *m, *d; + PyObject *d; PyObject *tuple; PyObject *e; + /* perform any initialisation required by the library here */ - m = Py_InitModule("gio._gio", pygio_functions); - d = PyModule_GetDict(m); + d = PyModule_GetDict(module); g_type_init(); pyglib_init(); - init_pygobject_check(2, 15, 2); + if (pygobject_init(2, 15, 2) == NULL) + return -1; pygio_register_classes(d); - pygio_add_constants(m, "G_IO_"); + pygio_add_constants(module, "G_IO_"); - PyModule_AddStringConstant(m, "ERROR", g_quark_to_string(G_IO_ERROR)); + PyModule_AddStringConstant(module, "ERROR", g_quark_to_string(G_IO_ERROR)); e = pyglib_register_exception_for_domain("gio.Error", G_IO_ERROR); PyDict_SetItemString(d, "Error", e); Py_DECREF(e); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_TYPE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_TYPE", G_FILE_ATTRIBUTE_STANDARD_TYPE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_IS_HIDDEN", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_HIDDEN", G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_IS_BACKUP", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_BACKUP", G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_IS_SYMLINK", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_SYMLINK", G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL", G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_NAME", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_NAME", G_FILE_ATTRIBUTE_STANDARD_NAME); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME", G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_EDIT_NAME", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_EDIT_NAME", G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_COPY_NAME", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_COPY_NAME", G_FILE_ATTRIBUTE_STANDARD_COPY_NAME); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_DESCRIPTION", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_DESCRIPTION", G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_ICON", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_ICON", G_FILE_ATTRIBUTE_STANDARD_ICON); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE", G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE", G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_SIZE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SIZE", G_FILE_ATTRIBUTE_STANDARD_SIZE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET", G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_TARGET_URI", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_TARGET_URI", G_FILE_ATTRIBUTE_STANDARD_TARGET_URI); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_STANDARD_SORT_ORDER", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_STANDARD_SORT_ORDER", G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ETAG_VALUE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ETAG_VALUE", G_FILE_ATTRIBUTE_ETAG_VALUE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ID_FILE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ID_FILE", G_FILE_ATTRIBUTE_ID_FILE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ID_FILESYSTEM", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ID_FILESYSTEM", G_FILE_ATTRIBUTE_ID_FILESYSTEM); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_READ", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_READ", G_FILE_ATTRIBUTE_ACCESS_CAN_READ); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_WRITE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_WRITE", G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE", G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_DELETE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_DELETE", G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_TRASH", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_TRASH", G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_ACCESS_CAN_RENAME", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_ACCESS_CAN_RENAME", G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT", G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT", G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT", G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE", G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI", G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_MODIFIED", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_MODIFIED", G_FILE_ATTRIBUTE_TIME_MODIFIED); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_MODIFIED_USEC", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_MODIFIED_USEC", G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_ACCESS", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_ACCESS", G_FILE_ATTRIBUTE_TIME_ACCESS); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_ACCESS_USEC", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_ACCESS_USEC", G_FILE_ATTRIBUTE_TIME_ACCESS_USEC); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_CHANGED", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CHANGED", G_FILE_ATTRIBUTE_TIME_CHANGED); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_CHANGED_USEC", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CHANGED_USEC", G_FILE_ATTRIBUTE_TIME_CHANGED_USEC); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_CREATED", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CREATED", G_FILE_ATTRIBUTE_TIME_CREATED); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TIME_CREATED_USEC", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TIME_CREATED_USEC", G_FILE_ATTRIBUTE_TIME_CREATED_USEC); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_DEVICE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_DEVICE", G_FILE_ATTRIBUTE_UNIX_DEVICE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_INODE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_INODE", G_FILE_ATTRIBUTE_UNIX_INODE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_MODE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_MODE", G_FILE_ATTRIBUTE_UNIX_MODE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_NLINK", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_NLINK", G_FILE_ATTRIBUTE_UNIX_NLINK); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_UID", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_UID", G_FILE_ATTRIBUTE_UNIX_UID); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_GID", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_GID", G_FILE_ATTRIBUTE_UNIX_GID); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_RDEV", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_RDEV", G_FILE_ATTRIBUTE_UNIX_RDEV); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_BLOCK_SIZE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_BLOCK_SIZE", G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_BLOCKS", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_BLOCKS", G_FILE_ATTRIBUTE_UNIX_BLOCKS); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT", G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_DOS_IS_ARCHIVE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_DOS_IS_ARCHIVE", G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_DOS_IS_SYSTEM", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_DOS_IS_SYSTEM", G_FILE_ATTRIBUTE_DOS_IS_SYSTEM); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_OWNER_USER", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_USER", G_FILE_ATTRIBUTE_OWNER_USER); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_OWNER_USER_REAL", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_USER_REAL", G_FILE_ATTRIBUTE_OWNER_USER_REAL); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_OWNER_GROUP", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_OWNER_GROUP", G_FILE_ATTRIBUTE_OWNER_GROUP); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_THUMBNAIL_PATH", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_THUMBNAIL_PATH", G_FILE_ATTRIBUTE_THUMBNAIL_PATH); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_THUMBNAILING_FAILED", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_THUMBNAILING_FAILED", G_FILE_ATTRIBUTE_THUMBNAILING_FAILED); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_FILESYSTEM_SIZE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_SIZE", G_FILE_ATTRIBUTE_FILESYSTEM_SIZE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_FILESYSTEM_FREE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_FREE", G_FILE_ATTRIBUTE_FILESYSTEM_FREE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_FILESYSTEM_TYPE", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_TYPE", G_FILE_ATTRIBUTE_FILESYSTEM_TYPE); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_FILESYSTEM_READONLY", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_READONLY", G_FILE_ATTRIBUTE_FILESYSTEM_READONLY); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW", G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_GVFS_BACKEND", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_GVFS_BACKEND", G_FILE_ATTRIBUTE_GVFS_BACKEND); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_SELINUX_CONTEXT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_SELINUX_CONTEXT", G_FILE_ATTRIBUTE_SELINUX_CONTEXT); - PyModule_AddStringConstant(m, "FILE_ATTRIBUTE_TRASH_ITEM_COUNT", + PyModule_AddStringConstant(module, "FILE_ATTRIBUTE_TRASH_ITEM_COUNT", G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT); - - PyModule_AddStringConstant(m, "ERROR", g_quark_to_string(G_IO_ERROR)); + + PyModule_AddStringConstant(module, "ERROR", g_quark_to_string(G_IO_ERROR)); /* pygio version */ tuple = Py_BuildValue ("(iii)", PYGIO_MAJOR_VERSION, PYGIO_MINOR_VERSION, PYGIO_MICRO_VERSION); - PyDict_SetItemString(d, "pygio_version", tuple); + PyDict_SetItemString(d, "pygio_version", tuple); Py_DECREF(tuple); + + return 0; } diff --git a/gio/pygio-utils.c b/gio/pygio-utils.c index be41453..f89c4b9 100644 --- a/gio/pygio-utils.c +++ b/gio/pygio-utils.c @@ -22,6 +22,7 @@ */ #include "pygio-utils.h" +#include /** * pygio_check_cancellable: @@ -115,14 +116,28 @@ pygio_pylist_to_uri_glist(PyObject *pyfile_list) len = PySequence_Size(pyfile_list); for (i = 0; i < len; i++) { - item = PySequence_GetItem(pyfile_list, i); - if (!PyString_Check(item)) { + item = PySequence_GetItem(pyfile_list, i); + if (!PYGLIB_PyUnicode_Check(item)) { PyErr_SetString(PyExc_TypeError, "files must be strings"); g_list_free(file_list); return NULL; } - file_list = g_list_prepend(file_list, PyString_AsString(item)); + +#if PY_VERSION_HEX < 0x03000000 + file_list = g_list_prepend(file_list, g_strdup(PyString_AsString(item))); +#else + { + PyObject *utf8_bytes_obj = PyUnicode_AsUTF8String (item); + if (!utf8_bytes_obj) { + g_list_free(file_list); + return NULL; + } + file_list = g_list_prepend(file_list, g_strdup(PyBytes_AsString(utf8_bytes_obj))); + Py_DECREF (utf8_bytes_obj); + } +#endif + } file_list = g_list_reverse(file_list); @@ -144,9 +159,9 @@ strv_to_pylist (char **strv) len = strv ? g_strv_length (strv) : 0; list = PyList_New (len); - for (i = 0; i < len; i++) - PyList_SetItem (list, i, PyString_FromString (strv[i])); - + for (i = 0; i < len; i++) { + PyList_SetItem (list, i, PYGLIB_PyUnicode_FromString (strv[i])); + } return list; } @@ -191,7 +206,7 @@ pylist_to_strv (PyObject *list, return FALSE; } - if (!PyString_Check (item)) + if (!PYGLIB_PyUnicode_Check (item)) { Py_DECREF (item); g_strfreev (ret); @@ -199,7 +214,20 @@ pylist_to_strv (PyObject *list, return FALSE; } +#if PY_VERSION_HEX < 0x03000000 ret[i] = g_strdup (PyString_AsString (item)); +#else + { + PyObject *utf8_bytes_obj = PyUnicode_AsUTF8String (item); + if (!utf8_bytes_obj) { + Py_DECREF (item); + g_strfreev (ret); + return FALSE; + } + ret[i] = g_strdup (PyBytes_AsString(utf8_bytes_obj)); + Py_DECREF (utf8_bytes_obj); + } +#endif Py_DECREF (item); } diff --git a/glib/Makefile.in b/glib/Makefile.in index ffaeb4c..5fddbf2 100644 --- a/glib/Makefile.in +++ b/glib/Makefile.in @@ -170,6 +170,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/glib/glibmodule.c b/glib/glibmodule.c index f794d5d..ebea163 100644 --- a/glib/glibmodule.c +++ b/glib/glibmodule.c @@ -68,19 +68,19 @@ get_handler_priority(gint *priority, PyObject *kwargs) } pos = 0; PyDict_Next(kwargs, &pos, &key, &val); - if (!_PyUnicode_Check(key)) { + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "keyword argument name is not a string"); return -1; } - if (strcmp(_PyUnicode_AsString(key), "priority") != 0) { + if (strcmp(PYGLIB_PyUnicode_AsString(key), "priority") != 0) { PyErr_SetString(PyExc_TypeError, "only 'priority' keyword argument accepted"); return -1; } - *priority = _PyLong_AsLong(val); + *priority = PYGLIB_PyLong_AsLong(val); if (PyErr_Occurred()) { PyErr_Clear(); PyErr_SetString(PyExc_ValueError, "could not get priority value"); @@ -135,7 +135,7 @@ pyglib_idle_add(PyObject *self, PyObject *args, PyObject *kwargs) handler_id = g_idle_add_full(priority, _pyglib_handler_marshal, data, _pyglib_destroy_notify); - return _PyLong_FromLong(handler_id); + return PYGLIB_PyLong_FromLong(handler_id); } @@ -175,7 +175,7 @@ pyglib_timeout_add(PyObject *self, PyObject *args, PyObject *kwargs) handler_id = g_timeout_add_full(priority, interval, _pyglib_handler_marshal, data, _pyglib_destroy_notify); - return _PyLong_FromLong(handler_id); + return PYGLIB_PyLong_FromLong(handler_id); } static PyObject * @@ -214,7 +214,7 @@ pyglib_timeout_add_seconds(PyObject *self, PyObject *args, PyObject *kwargs) handler_id = g_timeout_add_seconds_full(priority, interval, _pyglib_handler_marshal, data, _pyglib_destroy_notify); - return _PyLong_FromLong(handler_id); + return PYGLIB_PyLong_FromLong(handler_id); } static gboolean @@ -305,7 +305,7 @@ pyglib_io_add_watch(PyObject *self, PyObject *args, PyObject *kwargs) (GDestroyNotify)_pyglib_destroy_notify); g_io_channel_unref(iochannel); - return _PyLong_FromLong(handler_id); + return PYGLIB_PyLong_FromLong(handler_id); } static PyObject * @@ -385,7 +385,7 @@ pyglib_child_watch_add(PyObject *unused, PyObject *args, PyObject *kwargs) Py_INCREF(child_data->data); id = g_child_watch_add_full(priority, pid, child_watch_func, child_data, child_watch_dnotify); - return _PyLong_FromLong(id); + return PYGLIB_PyLong_FromLong(id); } static PyObject * @@ -402,7 +402,7 @@ pyglib_markup_escape_text(PyObject *unused, PyObject *args, PyObject *kwargs) return NULL; text_out = g_markup_escape_text(text_in, text_size); - retval = _PyUnicode_FromString(text_out); + retval = PYGLIB_PyUnicode_FromString(text_out); g_free(text_out); return retval; } @@ -417,12 +417,10 @@ pyglib_get_current_time(PyObject *unused) } static PyObject* -pyglib_get_user_cache_dir(PyObject *self) +get_user_dir(const char *path) { - const char *path = g_get_user_cache_dir(); - if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -432,27 +430,19 @@ pyglib_get_user_cache_dir(PyObject *self) static PyObject* pyglib_get_user_config_dir(PyObject *self) { - const char *path = g_get_user_config_dir(); + return get_user_dir(g_get_user_config_dir()); +} - if (path) - return _PyUnicode_FromString(path); - else { - Py_INCREF(Py_None); - return Py_None; - } +static PyObject* +pyglib_get_user_cache_dir(PyObject *self) +{ + return get_user_dir(g_get_user_cache_dir()); } static PyObject* pyglib_get_user_data_dir(PyObject *self) { - const char *path = g_get_user_data_dir(); - - if (path) - return _PyUnicode_FromString(path); - else { - Py_INCREF(Py_None); - return Py_None; - } + return get_user_dir(g_get_user_data_dir()); } static PyObject * @@ -469,7 +459,7 @@ pyglib_get_user_special_dir(PyObject *unused, PyObject *args, PyObject *kwargs) path = g_get_user_special_dir(directory); if (path) - return _PyUnicode_FromString(path); + return PYGLIB_PyUnicode_FromString(path); else { Py_INCREF(Py_None); return Py_None; @@ -479,7 +469,7 @@ pyglib_get_user_special_dir(PyObject *unused, PyObject *args, PyObject *kwargs) static PyObject * pyglib_main_depth(PyObject *unused) { - return _PyLong_FromLong(g_main_depth()); + return PYGLIB_PyLong_FromLong(g_main_depth()); } static PyObject * @@ -535,7 +525,7 @@ pyglib_filename_from_utf8(PyObject *self, PyObject *args) g_free(filename); return NULL; } - py_filename = _PyUnicode_FromStringAndSize(filename, bytes_written); + py_filename = PYGLIB_PyUnicode_FromStringAndSize(filename, bytes_written); g_free(filename); return py_filename; } @@ -551,19 +541,19 @@ pyglib_get_application_name(PyObject *self) Py_INCREF(Py_None); return Py_None; } - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); } static PyObject* pyglib_set_application_name(PyObject *self, PyObject *arg) { - if (!PyString_Check(arg)) { + if (!PYGLIB_PyUnicode_Check(arg)) { PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", - PyString_AS_STRING(PyObject_Repr(arg))); + PYGLIB_PyUnicode_AsString(PyObject_Repr(arg))); return NULL; } - g_set_application_name(PyString_AS_STRING(arg)); + g_set_application_name(PYGLIB_PyUnicode_AsString(arg)); Py_INCREF(Py_None); return Py_None; } @@ -578,19 +568,19 @@ pyglib_get_prgname(PyObject *self) Py_INCREF(Py_None); return Py_None; } - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); } static PyObject* pyglib_set_prgname(PyObject *self, PyObject *arg) { - if (!PyString_Check(arg)) { + if (!PYGLIB_PyUnicode_Check(arg)) { PyErr_Format(PyExc_TypeError, "first argument must be a string, not '%s'", - PyString_AS_STRING(PyObject_Repr(arg))); + PYGLIB_PyUnicode_AsString(PyObject_Repr(arg))); return NULL; } - g_set_prgname(PyString_AS_STRING(arg)); + g_set_prgname(PYGLIB_PyUnicode_AsString(arg)); Py_INCREF(Py_None); return Py_None; } @@ -608,11 +598,81 @@ pyglib_find_program_in_path(PyObject *unused, PyObject *args, PyObject *kwargs) return NULL; ret = g_find_program_in_path(program); - retval = _PyUnicode_FromString(ret); + retval = PYGLIB_PyUnicode_FromString(ret); g_free(ret); return retval; } +static PyObject * +pyglib_uri_list_extract_uris(PyObject *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = { "uri_list", NULL }; + char *uri_list; + char **uris, **tmp; + int i = 0, j; + PyObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:uri_list_extract_uris", kwlist, &uri_list)) + return NULL; + + uris = (char **)g_uri_list_extract_uris(uri_list); + if (!uris) { + Py_INCREF(Py_None); + return Py_None; + } + + tmp = uris; + while (*tmp) + tmp++, i++; + + ret = PyTuple_New(i); + for (j = 0; j < i; j++) + PyTuple_SetItem(ret, j, PyString_FromString(uris[j])); + + g_strfreev(uris); + + return ret; +} + +/* FIXME: we should use strv_to_pylist (in pygio-utils.h) here, but that + * function should be moved into pyglib first. See + * https://bugzilla.gnome.org/show_bug.cgi?id=630508 + */ +static PyObject * +tuple_of_strings_from_dirs(const gchar* const *dirs) +{ + char **tmp; + int i = 0, j; + PyObject *ret; + + if (!dirs) { + Py_INCREF(Py_None); + return Py_None; + } + + tmp = (char **)dirs; + while (*tmp) + tmp++, i++; + + ret = PyTuple_New(i); + for (j = 0; j < i; j++) + PyTuple_SetItem(ret, j, PYGLIB_PyUnicode_FromString(dirs[j])); + + return ret; +} + +static PyObject* +pyglib_get_system_config_dirs(PyObject *self) +{ + return tuple_of_strings_from_dirs(g_get_system_config_dirs()); +} + +static PyObject* +pyglib_get_system_data_dirs(PyObject *self) +{ + return tuple_of_strings_from_dirs(g_get_system_data_dirs()); +} + static PyMethodDef _glib_functions[] = { { "threads_init", (PyCFunction) pyglib_threads_init, METH_NOARGS, @@ -708,6 +768,16 @@ static PyMethodDef _glib_functions[] = { (PyCFunction)pyglib_markup_escape_text, METH_VARARGS|METH_KEYWORDS }, { "find_program_in_path", (PyCFunction)pyglib_find_program_in_path, METH_VARARGS|METH_KEYWORDS }, + { "uri_list_extract_uris", + (PyCFunction)pyglib_uri_list_extract_uris, METH_VARARGS|METH_KEYWORDS, + "uri_list_extract_uris(uri_list) -> tuple of strings holding URIs\n" + "Splits an string containing an URI list conforming to the \n" + "text/uri-list mime type defined in RFC 2483 into individual URIs, \n" + "discarding any comments. The URIs are not validated." }, + { "get_system_config_dirs", + (PyCFunction)pyglib_get_system_config_dirs, METH_NOARGS }, + { "get_system_data_dirs", + (PyCFunction)pyglib_get_system_data_dirs, METH_NOARGS }, { NULL, NULL, 0 } }; diff --git a/glib/option.py b/glib/option.py index 027752f..bdfbe1d 100644 --- a/glib/option.py +++ b/glib/option.py @@ -34,6 +34,13 @@ import optparse from optparse import OptParseError, OptionError, OptionValueError, \ BadOptionError, OptionConflictError +if sys.version_info >= (3, 0): + _basestring = str + _bytes = lambda s: s.encode() +else: + _basestring = basestring + _bytes = str + import glib _glib = sys.modules['glib._glib'] @@ -42,7 +49,7 @@ __all__ = [ "OptionError", "OptionValueError", "BadOptionError", - "OptionConflictError" + "OptionConflictError", "Option", "OptionGroup", "OptionParser", @@ -110,10 +117,10 @@ class Option(optparse.Option): flags = 0 if self.hidden: - self.flags |= _glib.OPTION_FLAG_HIDDEN + flags |= _glib.OPTION_FLAG_HIDDEN if self.in_main: - self.flags |= _glib.OPTION_FLAG_IN_MAIN + flags |= _glib.OPTION_FLAG_IN_MAIN if self.takes_value(): if self.optional_arg: @@ -125,10 +132,10 @@ class Option(optparse.Option): flags |= _glib.OPTION_FLAG_FILENAME for (long_name, short_name) in zip(self._long_opts, self._short_opts): - yield (long_name[2:], short_name[1], flags, self.help, self.metavar) + yield (long_name[2:], _bytes(short_name[1]), flags, self.help, self.metavar) for long_name in self._long_opts[len(self._short_opts):]: - yield (long_name[2:], '\0', flags, self.help, self.metavar) + yield (long_name[2:], _bytes('\0'), flags, self.help, self.metavar) class OptionGroup(optparse.OptionGroup): """A group of command line options. @@ -199,6 +206,7 @@ class OptionGroup(optparse.OptionGroup): entries = [] for option in self.option_list: entries.extend(option._to_goptionentries()) + group.add_entries(entries) return group @@ -214,7 +222,7 @@ class OptionGroup(optparse.OptionGroup): def set_values_to_defaults(self): for option in self.option_list: default = self.defaults.get(option.dest) - if isinstance(default, basestring): + if isinstance(default, _basestring): opt_str = option.get_opt_string() self.defaults[option.dest] = option.check_value( opt_str, default) @@ -292,7 +300,7 @@ class OptionParser(optparse.OptionParser): return context def add_option_group(self, *args, **kwargs): - if isinstance(args[0], basestring): + if isinstance(args[0], _basestring): optparse.OptionParser.add_option_group(self, OptionGroup(self, *args, **kwargs)) return diff --git a/glib/pygiochannel.c b/glib/pygiochannel.c index 4c935e8..f7e2bc4 100644 --- a/glib/pygiochannel.c +++ b/glib/pygiochannel.c @@ -39,17 +39,23 @@ py_io_channel_next(PyGIOChannel *self) return NULL; } - ret_obj = _PyUnicode_FromStringAndSize(str_return, length); + ret_obj = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); return ret_obj; } -static int -py_io_channel_compare(PyGIOChannel *self, PyGIOChannel *v) +static PyObject* +py_io_channel_richcompare(PyObject *self, PyObject *other, int op) { - if (self->channel == v->channel) return 0; - if (self->channel > v->channel) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && + Py_TYPE(self) == &PyGIOChannel_Type) { + return _pyglib_generic_ptr_richcompare(((PyGIOChannel*)self)->channel, + ((PyGIOChannel*)other)->channel, + op); + } else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static PyObject* @@ -88,7 +94,7 @@ py_io_channel_shutdown(PyGIOChannel* self, PyObject *args, PyObject *kwargs) if (pyglib_error_check(&error)) return NULL; - return _PyLong_FromLong(ret); + return PYGLIB_PyLong_FromLong(ret); } /* character encoding conversion involved functions. @@ -112,7 +118,7 @@ py_io_channel_set_buffer_size(PyGIOChannel* self, PyObject *args, PyObject *kwar static PyObject* py_io_channel_get_buffer_size(PyGIOChannel* self) { - return _PyLong_FromLong(g_io_channel_get_buffer_size(self->channel)); + return PYGLIB_PyLong_FromLong(g_io_channel_get_buffer_size(self->channel)); } static PyObject* @@ -133,7 +139,7 @@ py_io_channel_set_buffered(PyGIOChannel* self, PyObject *args, PyObject *kwargs) static PyObject* py_io_channel_get_buffered(PyGIOChannel* self) { - return _PyLong_FromLong(g_io_channel_get_buffered(self->channel)); + return PYGLIB_PyLong_FromLong(g_io_channel_get_buffered(self->channel)); } static PyObject* @@ -164,7 +170,7 @@ py_io_channel_get_encoding(PyGIOChannel* self) return Py_None; } - return _PyUnicode_FromString(encoding); + return PYGLIB_PyUnicode_FromString(encoding); } #define CHUNK_SIZE (8 * 1024) @@ -183,7 +189,7 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) return NULL; if (max_count == 0) - return _PyUnicode_FromString(""); + return PYGLIB_PyUnicode_FromString(""); while (status == G_IO_STATUS_NORMAL && (max_count == -1 || total_read < max_count)) { @@ -200,16 +206,16 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) } if ( ret_obj == NULL ) { - ret_obj = _PyUnicode_FromStringAndSize((char *)NULL, buf_size); + ret_obj = PYGLIB_PyBytes_FromStringAndSize((char *)NULL, buf_size); if (ret_obj == NULL) goto failure; } - else if (buf_size + total_read > _PyUnicode_GET_SIZE(ret_obj)) { - if (_PyUnicode_Resize(&ret_obj, buf_size + total_read) == -1) + else if (buf_size + total_read > PYGLIB_PyBytes_Size(ret_obj)) { + if (PYGLIB_PyBytes_Resize(&ret_obj, buf_size + total_read) == -1) goto failure; } - buf = _PyUnicode_AS_STRING(ret_obj) + total_read; + buf = PYGLIB_PyBytes_AsString(ret_obj) + total_read; pyglib_unblock_threads(); status = g_io_channel_read_chars(self->channel, buf, buf_size, @@ -221,10 +227,28 @@ py_io_channel_read_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) total_read += single_read; } - if ( total_read != _PyUnicode_GET_SIZE(ret_obj) ) { - if (_PyUnicode_Resize(&ret_obj, total_read) == -1) + if ( total_read != PYGLIB_PyBytes_Size(ret_obj) ) { + if (PYGLIB_PyBytes_Resize(&ret_obj, total_read) == -1) + goto failure; + } + +#if PY_VERSION_HEX >= 0x03000000 + /* If this is not UTF8 encoded channel return the raw bytes */ + if (g_io_channel_get_encoding(self->channel) != NULL) + return ret_obj; + + /* convert to Unicode string */ + { + PyObject *unicode_obj; + + unicode_obj = PyUnicode_FromString(PyBytes_AS_STRING(ret_obj)); + if (unicode_obj == NULL) goto failure; + Py_DECREF(ret_obj); + ret_obj = unicode_obj; } +#endif + return ret_obj; failure: @@ -252,7 +276,7 @@ py_io_channel_write_chars(PyGIOChannel* self, PyObject *args, PyObject *kwargs) if (pyglib_error_check(&error)) return NULL; - return _PyLong_FromLong(count); + return PYGLIB_PyLong_FromLong(count); } static PyObject* @@ -278,13 +302,13 @@ py_io_channel_write_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) PyErr_Clear(); goto normal_exit; } - if (!_PyUnicode_Check(value)) { + if (!PYGLIB_PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "glib.IOChannel.writelines must" " be sequence/iterator of strings"); Py_DECREF(iter); return NULL; } - _PyUnicode_AsStringAndSize(value, &buf, &buf_len); + PYGLIB_PyUnicode_AsStringAndSize(value, &buf, &buf_len); pyglib_unblock_threads(); status = g_io_channel_write_chars(self->channel, buf, buf_len, &count, &error); pyglib_unblock_threads(); @@ -312,7 +336,7 @@ py_io_channel_flush(PyGIOChannel* self) if (pyglib_error_check(&error)) return NULL; - return _PyLong_FromLong(status); + return PYGLIB_PyLong_FromLong(status); } static PyObject* @@ -331,19 +355,19 @@ py_io_channel_set_flags(PyGIOChannel* self, PyObject *args, PyObject *kwargs) if (pyglib_error_check(&error)) return NULL; - return _PyLong_FromLong(status); + return PYGLIB_PyLong_FromLong(status); } static PyObject* py_io_channel_get_flags(PyGIOChannel* self) { - return _PyLong_FromLong(g_io_channel_get_flags(self->channel)); + return PYGLIB_PyLong_FromLong(g_io_channel_get_flags(self->channel)); } static PyObject* py_io_channel_get_buffer_condition(PyGIOChannel* self) { - return _PyLong_FromLong(g_io_channel_get_buffer_condition(self->channel)); + return PYGLIB_PyLong_FromLong(g_io_channel_get_buffer_condition(self->channel)); } static PyObject* @@ -494,7 +518,7 @@ py_io_channel_win32_poll(PyObject *self, PyObject *args, PyObject *kwargs) pyfd = PyList_GET_ITEM(pyfds, i); ((PyGPollFD *) pyfd)->pollfd = pollfd[i]; } - return _PyLong_FromLong(result); + return PYGLIB_PyLong_FromLong(result); } static PyObject * @@ -538,7 +562,7 @@ py_io_channel_read_line(PyGIOChannel* self, PyObject *args, PyObject *kwargs) &terminator_pos, &error); if (pyglib_error_check(&error)) return NULL; - ret_obj = _PyUnicode_FromStringAndSize(str_return, length); + ret_obj = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); return ret_obj; } @@ -567,7 +591,7 @@ py_io_channel_read_lines(PyGIOChannel* self, PyObject *args, PyObject *kwargs) Py_DECREF(line); return NULL; } - line = _PyUnicode_FromStringAndSize(str_return, length); + line = PYGLIB_PyUnicode_FromStringAndSize(str_return, length); g_free(str_return); if (PyList_Append(list, line)) { Py_DECREF(line); @@ -608,7 +632,7 @@ py_io_channel_seek(PyGIOChannel* self, PyObject *args, PyObject *kwargs) if (pyglib_error_check(&error)) return NULL; - return _PyLong_FromLong(status); + return PYGLIB_PyLong_FromLong(status); } #if 0 // Not wrapped @@ -643,29 +667,29 @@ static PyMemberDef py_io_channel_members[] = { }; static PyMethodDef py_io_channel_methods[] = { - { "close", (PyCFunction)py_io_channel_shutdown, METH_KEYWORDS }, + { "close", (PyCFunction)py_io_channel_shutdown, METH_VARARGS|METH_KEYWORDS }, { "flush", (PyCFunction)py_io_channel_flush, METH_NOARGS }, - { "set_encoding", (PyCFunction)py_io_channel_set_encoding, METH_KEYWORDS }, + { "set_encoding", (PyCFunction)py_io_channel_set_encoding, METH_VARARGS|METH_KEYWORDS }, { "get_encoding", (PyCFunction)py_io_channel_get_encoding, METH_NOARGS }, - { "set_buffered", (PyCFunction)py_io_channel_set_buffered, METH_KEYWORDS }, + { "set_buffered", (PyCFunction)py_io_channel_set_buffered, METH_VARARGS|METH_KEYWORDS }, { "get_buffered", (PyCFunction)py_io_channel_get_buffered, METH_NOARGS }, - { "set_buffer_size", (PyCFunction)py_io_channel_set_buffer_size, METH_KEYWORDS }, + { "set_buffer_size", (PyCFunction)py_io_channel_set_buffer_size, METH_VARARGS|METH_KEYWORDS }, { "get_buffer_size", (PyCFunction)py_io_channel_get_buffer_size, METH_NOARGS }, - { "read", (PyCFunction)py_io_channel_read_chars, METH_KEYWORDS }, - { "readline", (PyCFunction)py_io_channel_read_line, METH_KEYWORDS }, - { "readlines", (PyCFunction)py_io_channel_read_lines, METH_KEYWORDS }, - { "write", (PyCFunction)py_io_channel_write_chars, METH_KEYWORDS }, - { "writelines", (PyCFunction)py_io_channel_write_lines, METH_KEYWORDS }, - { "set_flags", (PyCFunction)py_io_channel_set_flags, METH_KEYWORDS }, + { "read", (PyCFunction)py_io_channel_read_chars, METH_VARARGS|METH_KEYWORDS }, + { "readline", (PyCFunction)py_io_channel_read_line, METH_VARARGS|METH_KEYWORDS }, + { "readlines", (PyCFunction)py_io_channel_read_lines, METH_VARARGS|METH_KEYWORDS }, + { "write", (PyCFunction)py_io_channel_write_chars, METH_VARARGS|METH_KEYWORDS }, + { "writelines", (PyCFunction)py_io_channel_write_lines, METH_VARARGS|METH_KEYWORDS }, + { "set_flags", (PyCFunction)py_io_channel_set_flags, METH_VARARGS|METH_KEYWORDS }, { "get_flags", (PyCFunction)py_io_channel_get_flags, METH_NOARGS }, { "get_buffer_condition", (PyCFunction)py_io_channel_get_buffer_condition, METH_NOARGS }, - { "set_close_on_unref", (PyCFunction)py_io_channel_set_close_on_unref, METH_KEYWORDS }, + { "set_close_on_unref", (PyCFunction)py_io_channel_set_close_on_unref, METH_VARARGS | METH_KEYWORDS }, { "get_close_on_unref", (PyCFunction)py_io_channel_get_close_on_unref, METH_NOARGS }, - { "add_watch", (PyCFunction)py_io_channel_add_watch, METH_KEYWORDS }, - { "seek", (PyCFunction)py_io_channel_seek, METH_KEYWORDS }, + { "add_watch", (PyCFunction)py_io_channel_add_watch, METH_VARARGS|METH_KEYWORDS }, + { "seek", (PyCFunction)py_io_channel_seek, METH_VARARGS|METH_KEYWORDS }, #ifdef G_OS_WIN32 - { "win32_make_pollfd", (PyCFunction)py_io_channel_win32_make_pollfd, METH_KEYWORDS }, - { "win32_poll", (PyCFunction)py_io_channel_win32_poll, METH_KEYWORDS|METH_STATIC }, + { "win32_make_pollfd", (PyCFunction)py_io_channel_win32_make_pollfd, METH_VARARGS | METH_KEYWORDS }, + { "win32_poll", (PyCFunction)py_io_channel_win32_poll, METH_VARARGS|METH_KEYWORDS|METH_STATIC }, #endif { NULL, NULL, 0 } }; @@ -732,7 +756,7 @@ pyglib_iochannel_register_types(PyObject *d) PyGIOChannel_Type.tp_members = py_io_channel_members; PyGIOChannel_Type.tp_methods = py_io_channel_methods; PyGIOChannel_Type.tp_hash = (hashfunc)py_io_channel_hash; - PyGIOChannel_Type.tp_compare = (cmpfunc)py_io_channel_compare; + PyGIOChannel_Type.tp_richcompare = (richcmpfunc)py_io_channel_richcompare; PyGIOChannel_Type.tp_iter = (getiterfunc)py_io_channel_get_iter; PyGIOChannel_Type.tp_iternext = (iternextfunc)py_io_channel_next; diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h index 915a912..bb7bcad 100644 --- a/glib/pyglib-python-compat.h +++ b/glib/pyglib-python-compat.h @@ -41,31 +41,110 @@ typedef int Py_ssize_t; typedef inquiry lenfunc; #endif +#if PY_VERSION_HEX < 0x03000000 + +#define PYGLIB_INIT_FUNCTION(modname, fullpkgname, functions) \ +static int _pyglib_init_##modname(PyObject *module); \ +void init##modname(void) \ +{ \ + PyObject *module = Py_InitModule(fullpkgname, functions); \ + _pyglib_init_##modname(module); \ +} \ +static int _pyglib_init_##modname(PyObject *module) + +#else + +#define PYGLIB_INIT_FUNCTION(modname, fullpkgname, functions) \ +static struct PyModuleDef _##modname##module = { \ + PyModuleDef_HEAD_INIT, \ + fullpkgname, \ + NULL, \ + -1, \ + functions, \ + NULL, \ + NULL, \ + NULL, \ + NULL \ +}; \ +static int _pyglib_init_##modname(PyObject *module); \ +PyObject *PyInit_##modname(void) \ +{ \ + PyObject *module = PyModule_Create(&_##modname##module); \ + if (module == NULL) \ + return NULL; \ + if (_pyglib_init_##modname(module) != 0 ) {\ + Py_DECREF(module); \ + return NULL; \ + } \ + return module; \ +} \ +static int _pyglib_init_##modname(PyObject *module) + +#endif + /* Compilation on Python 2.x */ #if PY_VERSION_HEX < 0x03000000 #define RO READONLY -#define _PyUnicode_Check PyString_Check -#define _PyUnicode_AsString PyString_AsString -#define _PyUnicode_AsStringAndSize PyString_AsStringAndSize -#define _PyUnicode_FromString PyString_FromString -#define _PyUnicode_FromStringAndSize PyString_FromStringAndSize -#define _PyUnicode_FromFormat PyString_FromFormat -#define _PyUnicode_AS_STRING PyString_AS_STRING -#define _PyUnicode_GET_SIZE PyString_GET_SIZE -#define _PyUnicode_Resize _PyString_Resize -#define _PyUnicode_Type PyString_Type -#define _PyLong_Check PyInt_Check -#define _PyLong_FromLong PyInt_FromLong -#define _PyLong_AsLong PyInt_AsLong -#define _PyLongObject PyIntObject -#define _PyLong_Type PyInt_Type -#define _PyLong_AS_LONG PyInt_AS_LONG +#define PYGLIB_PyUnicode_Check PyString_Check +#define PYGLIB_PyUnicode_AsString PyString_AsString +#define PYGLIB_PyUnicode_AsStringAndSize PyString_AsStringAndSize +#define PYGLIB_PyUnicode_FromString PyString_FromString +#define PYGLIB_PyUnicode_FromStringAndSize PyString_FromStringAndSize +#define PYGLIB_PyUnicode_FromFormat PyString_FromFormat +#define PYGLIB_PyUnicode_AS_STRING PyString_AS_STRING +#define PYGLIB_PyUnicode_GET_SIZE PyString_GET_SIZE +#define PYGLIB_PyUnicode_Type PyString_Type + +#define PYGLIB_PyBytes_FromString PyString_FromString +#define PYGLIB_PyBytes_FromStringAndSize PyString_FromStringAndSize +#define PYGLIB_PyBytes_Resize _PyString_Resize +#define PYGLIB_PyBytes_AsString PyString_AsString +#define PYGLIB_PyBytes_Size PyString_Size +#define PYGLIB_PyBytes_Check PyString_Check + +#define PYGLIB_PyLong_Check PyInt_Check +#define PYGLIB_PyLong_FromLong PyInt_FromLong +#define PYGLIB_PyLong_FromSsize_t PyInt_FromSsize_t +#define PYGLIB_PyLong_FromSize_t PyInt_FromSize_t +#define PYGLIB_PyLong_AsLong PyInt_AsLong +#define PYGLIB_PyLongObject PyIntObject +#define PYGLIB_PyLong_Type PyInt_Type +#define PYGLIB_PyLong_AS_LONG PyInt_AS_LONG #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) + +#define PYGLIB_PyNumber_Long PyNumber_Int + +#ifndef PyVarObject_HEAD_INIT +#define PyVarObject_HEAD_INIT(base, size) \ + PyObject_HEAD_INIT(base) \ + size, +#endif + +#define PYGLIB_MODULE_START(symbol, modname) \ +DL_EXPORT(void) init##symbol(void) \ +{ \ + PyObject *module; \ + module = Py_InitModule(modname, symbol##_functions); +#define PYGLIB_MODULE_END } +#define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \ +PyTypeObject symbol = { \ + PyObject_HEAD_INIT(NULL) \ + 0, \ + typename, \ + sizeof(csymbol), \ + 0, \ +}; +#define PYGLIB_REGISTER_TYPE(d, type, name) \ + if (!type.tp_alloc) \ + type.tp_alloc = PyType_GenericAlloc; \ + if (!type.tp_new) \ + type.tp_new = PyType_GenericNew; \ + if (PyType_Ready(&type)) \ + return; \ + PyDict_SetItemString(d, name, (PyObject *)&type); + #else -#undef PYGLIB_MODULE_START -#undef PYGLIB_MODULE_END -#undef PYGLIB_DEFINE_TYPE -#undef PYGLIB_REGISTER_TYPE + #define PYGLIB_MODULE_START(symbol, modname) \ static struct PyModuleDef _##symbol##module = { \ @@ -99,22 +178,32 @@ PyTypeObject symbol = { \ return; \ PyDict_SetItemString(d, name, (PyObject *)&type); -#define _PyUnicode_Check PyUnicode_Check -#define _PyUnicode_AsString PyUnicode_AsString -#define _PyUnicode_AsStringAndSize(obj, buf, size) PyUnicode_AsStringAndSize(obj, size) -#define _PyUnicode_FromString PyUnicode_FromString -#define _PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize -#define _PyUnicode_FromFormat PyUnicode_FromFormat -#define _PyUnicode_AS_STRING _PyUnicode_AsString -#define _PyUnicode_GET_SIZE PyUnicode_GET_SIZE -#define _PyUnicode_Resize PyUnicode_Resize -#define _PyUnicode_Type PyUnicode_Type -#define _PyLong_Check PyLong_Check -#define _PyLong_FromLong PyLong_FromLong -#define _PyLong_AsLong PyLong_AsLong -#define _PyLong_AS_LONG PyLong_AS_LONG -#define _PyLongObject PyLongObject -#define _PyLong_Type PyLong_Type +#define PYGLIB_PyUnicode_Check PyUnicode_Check +#define PYGLIB_PyUnicode_AsString _PyUnicode_AsString +#define PYGLIB_PyUnicode_AsStringAndSize(obj, buf, size) \ + (((*(buf) = _PyUnicode_AsStringAndSize(obj, size)) != NULL) ? 0 : -1) +#define PYGLIB_PyUnicode_FromString PyUnicode_FromString +#define PYGLIB_PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize +#define PYGLIB_PyUnicode_FromFormat PyUnicode_FromFormat +#define PYGLIB_PyUnicode_GET_SIZE PyUnicode_GET_SIZE +#define PYGLIB_PyUnicode_Resize PyUnicode_Resize +#define PYGLIB_PyUnicode_Type PyUnicode_Type +#define PYGLIB_PyLong_Check PyLong_Check +#define PYGLIB_PyLong_FromLong PyLong_FromLong +#define PYGLIB_PyLong_AsLong PyLong_AsLong +#define PYGLIB_PyLong_AS_LONG(o) PyLong_AS_LONG((PyObject*)(o)) +#define PYGLIB_PyLongObject PyLongObject +#define PYGLIB_PyLong_Type PyLong_Type + +#define PYGLIB_PyBytes_FromString PyBytes_FromString +#define PYGLIB_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +#define PYGLIB_PyBytes_Resize(o, len) _PyBytes_Resize(o, len) +#define PYGLIB_PyBytes_AsString PyBytes_AsString +#define PYGLIB_PyBytes_Size PyBytes_Size +#define PYGLIB_PyBytes_Check PyBytes_Check + +#define PYGLIB_PyNumber_Long PyNumber_Long + #endif #endif /* __PYGLIB_PYTHON_COMPAT_H__ */ diff --git a/glib/pyglib.c b/glib/pyglib.c index a1bdbb9..07db579 100644 --- a/glib/pyglib.c +++ b/glib/pyglib.c @@ -61,7 +61,7 @@ pyglib_init(void) Py_XDECREF(traceback); PyErr_Format(PyExc_ImportError, "could not import glib (error was: %s)", - _PyUnicode_AsString(py_orig_exc)); + PYGLIB_PyUnicode_AsString(py_orig_exc)); Py_DECREF(py_orig_exc); } else { PyErr_SetString(PyExc_ImportError, @@ -264,7 +264,7 @@ pyglib_error_check(GError **error) if (exception_table != NULL) { PyObject *item; - item = PyDict_GetItem(exception_table, _PyLong_FromLong((*error)->domain)); + item = PyDict_GetItem(exception_table, PYGLIB_PyLong_FromLong((*error)->domain)); if (item != NULL) exc_type = item; } @@ -273,19 +273,19 @@ pyglib_error_check(GError **error) if ((*error)->domain) { PyObject_SetAttrString(exc_instance, "domain", - d=_PyUnicode_FromString(g_quark_to_string((*error)->domain))); + d=PYGLIB_PyUnicode_FromString(g_quark_to_string((*error)->domain))); Py_DECREF(d); } else PyObject_SetAttrString(exc_instance, "domain", Py_None); PyObject_SetAttrString(exc_instance, "code", - d=_PyLong_FromLong((*error)->code)); + d=PYGLIB_PyLong_FromLong((*error)->code)); Py_DECREF(d); if ((*error)->message) { PyObject_SetAttrString(exc_instance, "message", - d=_PyUnicode_FromString((*error)->message)); + d=PYGLIB_PyUnicode_FromString((*error)->message)); Py_DECREF(d); } else { PyObject_SetAttrString(exc_instance, "message", Py_None); @@ -338,28 +338,28 @@ pyglib_gerror_exception_check(GError **error) Py_XDECREF(traceback); py_message = PyObject_GetAttrString(value, "message"); - if (!py_message || !_PyUnicode_Check(py_message)) { + if (!py_message || !PYGLIB_PyUnicode_Check(py_message)) { bad_gerror_message = "glib.GError instances must have a 'message' string attribute"; goto bad_gerror; } py_domain = PyObject_GetAttrString(value, "domain"); - if (!py_domain || !_PyUnicode_Check(py_domain)) { + if (!py_domain || !PYGLIB_PyUnicode_Check(py_domain)) { bad_gerror_message = "glib.GError instances must have a 'domain' string attribute"; Py_DECREF(py_message); goto bad_gerror; } py_code = PyObject_GetAttrString(value, "code"); - if (!py_code || !_PyLong_Check(py_code)) { + if (!py_code || !PYGLIB_PyLong_Check(py_code)) { bad_gerror_message = "glib.GError instances must have a 'code' int attribute"; Py_DECREF(py_message); Py_DECREF(py_domain); goto bad_gerror; } - g_set_error(error, g_quark_from_string(_PyUnicode_AsString(py_domain)), - _PyLong_AsLong(py_code), _PyUnicode_AsString(py_message)); + g_set_error(error, g_quark_from_string(PYGLIB_PyUnicode_AsString(py_domain)), + PYGLIB_PyLong_AsLong(py_code), PYGLIB_PyUnicode_AsString(py_message)); Py_DECREF(py_message); Py_DECREF(py_code); @@ -368,7 +368,7 @@ pyglib_gerror_exception_check(GError **error) bad_gerror: Py_DECREF(value); - g_set_error(error, g_quark_from_static_string("pyglib"), 0, bad_gerror_message); + g_set_error(error, g_quark_from_static_string("pyglib"), 0, "%s", bad_gerror_message); PyErr_SetString(PyExc_ValueError, bad_gerror_message); PyErr_Print(); return -2; @@ -397,7 +397,7 @@ pyglib_register_exception_for_domain(gchar *name, exception_table = PyDict_New(); PyDict_SetItem(exception_table, - _PyLong_FromLong(error_domain), + PYGLIB_PyLong_FromLong(error_domain), exception); return exception; @@ -574,4 +574,90 @@ _pyglib_handler_marshal(gpointer user_data) return res; } +PyObject* +_pyglib_generic_ptr_richcompare(void* a, void *b, int op) +{ + PyObject *res; + + switch (op) { + + case Py_EQ: + res = (a == b) ? Py_True : Py_False; + break; + + case Py_NE: + res = (a != b) ? Py_True : Py_False; + break; + + case Py_LT: + res = (a < b) ? Py_True : Py_False; + break; + + case Py_LE: + res = (a <= b) ? Py_True : Py_False; + break; + + case Py_GT: + res = (a > b) ? Py_True : Py_False; + break; + + case Py_GE: + res = (a >= b) ? Py_True : Py_False; + break; + + default: + res = Py_NotImplemented; + break; + } + + Py_INCREF(res); + return res; +} + +PyObject* +_pyglib_generic_long_richcompare(long a, long b, int op) +{ + PyObject *res; + + switch (op) { + + case Py_EQ: + res = (a == b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + case Py_NE: + res = (a != b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + + case Py_LT: + res = (a < b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + case Py_LE: + res = (a <= b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + case Py_GT: + res = (a > b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + case Py_GE: + res = (a >= b) ? Py_True : Py_False; + Py_INCREF(res); + break; + + default: + res = Py_NotImplemented; + Py_INCREF(res); + break; + } + + return res; +} diff --git a/glib/pyglib.h b/glib/pyglib.h index 84bb36c..44ead47 100644 --- a/glib/pyglib.h +++ b/glib/pyglib.h @@ -53,6 +53,8 @@ PyObject * pyglib_float_from_timeval(GTimeVal timeval); /* Private: for gobject <-> glib interaction only. */ void _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback); +PyObject* _pyglib_generic_ptr_richcompare(void* a, void *b, int op); +PyObject* _pyglib_generic_long_richcompare(long a, long b, int op); #define pyglib_begin_allow_threads \ G_STMT_START { \ @@ -65,20 +67,6 @@ void _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback); PyEval_RestoreThread(_save); \ } G_STMT_END -#define PYGLIB_MODULE_START(symbol, modname) \ -DL_EXPORT(void) init##symbol(void) \ -{ \ - PyObject *module; \ - module = Py_InitModule(modname, symbol##_functions); -#define PYGLIB_MODULE_END } -#define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \ -PyTypeObject symbol = { \ - PyObject_HEAD_INIT(NULL) \ - 0, \ - typename, \ - sizeof(csymbol), \ - 0, \ -}; #define PYGLIB_REGISTER_TYPE(d, type, name) \ if (!type.tp_alloc) \ type.tp_alloc = PyType_GenericAlloc; \ @@ -88,6 +76,7 @@ PyTypeObject symbol = { \ return; \ PyDict_SetItemString(d, name, (PyObject *)&type); + G_END_DECLS #endif /* __PYGLIB_H__ */ diff --git a/glib/pygmaincontext.c b/glib/pygmaincontext.c index 186215a..43ca84e 100644 --- a/glib/pygmaincontext.c +++ b/glib/pygmaincontext.c @@ -51,12 +51,17 @@ pyg_main_context_dealloc(PyGMainContext *self) PyObject_Del(self); } -static int -pyg_main_context_compare(PyGMainContext *self, PyGMainContext *v) +static PyObject* +pyg_main_context_richcompare(PyObject *self, PyObject *other, int op) { - if (self->context == v->context) return 0; - if (self->context > v->context) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGMainContext_Type) + return _pyglib_generic_ptr_richcompare(((PyGMainContext*)self)->context, + ((PyGMainContext*)other)->context, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static PyObject * @@ -91,7 +96,7 @@ void pyglib_maincontext_register_types(PyObject *d) { PyGMainContext_Type.tp_dealloc = (destructor)pyg_main_context_dealloc; - PyGMainContext_Type.tp_compare = (cmpfunc)pyg_main_context_compare; + PyGMainContext_Type.tp_richcompare = pyg_main_context_richcompare; PyGMainContext_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGMainContext_Type.tp_methods = _PyGMainContext_methods; PyGMainContext_Type.tp_init = (initproc)pyg_main_context_init; diff --git a/glib/pygmainloop.c b/glib/pygmainloop.c index d9f048c..de74971 100644 --- a/glib/pygmainloop.c +++ b/glib/pygmainloop.c @@ -285,12 +285,17 @@ pyg_main_loop_dealloc(PyGMainLoop *self) PyObject_Del(self); } -static int -pyg_main_loop_compare(PyGMainLoop *self, PyGMainLoop *v) +static PyObject* +pyg_main_loop_richcompare(PyObject *self, PyObject *other, int op) { - if (self->loop == v->loop) return 0; - if (self->loop > v->loop) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGMainLoop_Type) + return _pyglib_generic_ptr_richcompare(((PyGMainLoop*)self)->loop, + ((PyGMainLoop*)other)->loop, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static PyObject * @@ -346,7 +351,7 @@ void pyglib_mainloop_register_types(PyObject *d) { PyGMainLoop_Type.tp_dealloc = (destructor)pyg_main_loop_dealloc; - PyGMainLoop_Type.tp_compare = (cmpfunc)pyg_main_loop_compare; + PyGMainLoop_Type.tp_richcompare = pyg_main_loop_richcompare; PyGMainLoop_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGMainLoop_Type.tp_methods = _PyGMainLoop_methods; PyGMainLoop_Type.tp_init = (initproc)pyg_main_loop_init; diff --git a/glib/pygoptioncontext.c b/glib/pygoptioncontext.c index 92ba901..1d67ac5 100644 --- a/glib/pygoptioncontext.c +++ b/glib/pygoptioncontext.c @@ -98,7 +98,7 @@ pyg_option_context_parse(PyGOptionContext *self, for (pos = 0; pos < argv_length; pos++) { arg = PyList_GetItem(argv, pos); - argv_content[pos] = g_strdup(_PyUnicode_AsString(arg)); + argv_content[pos] = g_strdup(PYGLIB_PyUnicode_AsString(arg)); if (argv_content[pos] == NULL) { g_strfreev(argv_content); @@ -126,7 +126,7 @@ pyg_option_context_parse(PyGOptionContext *self, new_argv = PyList_New(g_strv_length(argv_content)); for (pos = 0; pos < argv_length; pos++) { - arg = _PyUnicode_FromString(argv_content[pos]); + arg = PYGLIB_PyUnicode_FromString(argv_content[pos]); PyList_SetItem(new_argv, pos, arg); } @@ -272,13 +272,17 @@ pyg_option_context_add_group(PyGOptionContext *self, return Py_None; } -static int -pyg_option_context_compare(PyGOptionContext *self, PyGOptionContext *context) +static PyObject* +pyg_option_context_richcompare(PyObject *self, PyObject *other, int op) { - if (self->context == context->context) return 0; - if (self->context > context->context) - return 1; - return -1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGOptionContext_Type) + return _pyglib_generic_ptr_richcompare(((PyGOptionContext*)self)->context, + ((PyGOptionContext*)other)->context, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static PyObject * @@ -304,7 +308,7 @@ void pyglib_option_context_register_types(PyObject *d) { PyGOptionContext_Type.tp_dealloc = (destructor)pyg_option_context_dealloc; - PyGOptionContext_Type.tp_compare = (cmpfunc)pyg_option_context_compare; + PyGOptionContext_Type.tp_richcompare = pyg_option_context_richcompare; PyGOptionContext_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGOptionContext_Type.tp_methods = pyg_option_context_methods; PyGOptionContext_Type.tp_init = (initproc)pyg_option_context_init; diff --git a/glib/pygoptiongroup.c b/glib/pygoptiongroup.c index 70e4529..9345869 100644 --- a/glib/pygoptiongroup.c +++ b/glib/pygoptiongroup.c @@ -240,16 +240,18 @@ pyg_option_group_set_translation_domain(PyGOptionGroup *self, return Py_None; } -static int -pyg_option_group_compare(PyGOptionGroup *self, PyGOptionGroup *group) +static PyObject* +pyg_option_group_richcompare(PyObject *self, PyObject *other, int op) { - if (self->group == group->group) - return 0; - - if (self->group > group->group) - return 1; - - return -1; + if (Py_TYPE(self) == Py_TYPE(other) && + Py_TYPE(self) == &PyGOptionGroup_Type) { + return _pyglib_generic_ptr_richcompare(((PyGOptionGroup*)self)->group, + ((PyGOptionGroup*)other)->group, + op); + } else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static PyMethodDef pyg_option_group_methods[] = { @@ -262,7 +264,7 @@ void pyglib_option_group_register_types(PyObject *d) { PyGOptionGroup_Type.tp_dealloc = (destructor)pyg_option_group_dealloc; - PyGOptionGroup_Type.tp_compare = (cmpfunc)pyg_option_group_compare; + PyGOptionGroup_Type.tp_richcompare = pyg_option_group_richcompare; PyGOptionGroup_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGOptionGroup_Type.tp_methods = pyg_option_group_methods; PyGOptionGroup_Type.tp_init = (initproc)pyg_option_group_init; diff --git a/glib/pygsource.c b/glib/pygsource.c index 298b928..3587c38 100644 --- a/glib/pygsource.c +++ b/glib/pygsource.c @@ -82,7 +82,7 @@ source_repr(PyGSource *self, const char *type) g_snprintf(buf, sizeof(buf), "<%s glib source at 0x%lx>", desc, (long) self); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static PyObject * @@ -109,7 +109,7 @@ pyg_source_attach(PyGSource *self, PyObject *args, PyObject *kwargs) } id = g_source_attach(self->source, context); - return _PyLong_FromLong(id); + return PYGLIB_PyLong_FromLong(id); } static PyObject * @@ -255,12 +255,12 @@ pyg_source_get_current_time(PyGSource *self) } static PyMethodDef pyg_source_methods[] = { - { "attach", (PyCFunction)pyg_source_attach, METH_KEYWORDS }, + { "attach", (PyCFunction)pyg_source_attach, METH_VARARGS|METH_KEYWORDS }, { "destroy", (PyCFunction)pyg_source_destroy, METH_NOARGS }, { "set_callback", (PyCFunction)pyg_source_set_callback, METH_VARARGS }, { "get_context", (PyCFunction)pyg_source_get_context, METH_NOARGS }, { "add_poll", (PyCFunction)pyg_source_add_poll, METH_KEYWORDS }, - { "remove_poll", (PyCFunction)pyg_source_remove_poll, METH_KEYWORDS }, + { "remove_poll", (PyCFunction)pyg_source_remove_poll, METH_VARARGS|METH_KEYWORDS }, { "get_current_time", (PyCFunction)pyg_source_get_current_time, METH_NOARGS }, { NULL, NULL, 0 } }; @@ -283,7 +283,7 @@ pyg_source_get_priority(PyGSource *self, void *closure) { CHECK_DESTROYED(self, NULL); - return _PyLong_FromLong(g_source_get_priority(self->source)); + return PYGLIB_PyLong_FromLong(g_source_get_priority(self->source)); } static int @@ -296,12 +296,12 @@ pyg_source_set_priority(PyGSource *self, PyObject *value, void *closure) return -1; } - if (!_PyLong_Check(value)) { + if (!PYGLIB_PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "type mismatch"); return -1; } - g_source_set_priority(self->source, _PyLong_AsLong(value)); + g_source_set_priority(self->source, PYGLIB_PyLong_AsLong(value)); return 0; } @@ -339,7 +339,7 @@ pyg_source_get_id(PyGSource *self, void *closure) return NULL; } - return _PyLong_FromLong(g_source_get_id(self->source)); + return PYGLIB_PyLong_FromLong(g_source_get_id(self->source)); } static PyGetSetDef pyg_source_getsets[] = { @@ -426,7 +426,7 @@ pyg_source_prepare(GSource *source, gint *timeout) } ret = PyObject_IsTrue(PyTuple_GET_ITEM(t, 0)); - *timeout = _PyLong_AsLong(PyTuple_GET_ITEM(t, 1)); + *timeout = PYGLIB_PyLong_AsLong(PyTuple_GET_ITEM(t, 1)); if (*timeout == -1 && PyErr_Occurred()) { ret = FALSE; @@ -652,7 +652,7 @@ pyg_poll_fd_dealloc(PyGPollFD *self) static PyObject * pyg_poll_fd_repr(PyGPollFD *self) { - return _PyUnicode_FromFormat("", + return PYGLIB_PyUnicode_FromFormat("", self->pollfd.fd, self->pollfd.events, (long)self); } diff --git a/glib/pygspawn.c b/glib/pygspawn.c index cded501..75e2232 100644 --- a/glib/pygspawn.c +++ b/glib/pygspawn.c @@ -32,12 +32,12 @@ struct _PyGChildSetupData { PyObject *data; }; -PYGLIB_DEFINE_TYPE("glib.Pid", PyGPid_Type, _PyLongObject) +PYGLIB_DEFINE_TYPE("glib.Pid", PyGPid_Type, PYGLIB_PyLongObject) static PyObject * pyg_pid_close(PyObject *self, PyObject *args, PyObject *kwargs) { - g_spawn_close_pid(_PyLong_AsLong(self)); + g_spawn_close_pid(PYGLIB_PyLong_AsLong(self)); Py_INCREF(Py_None); return Py_None; } @@ -50,8 +50,8 @@ static PyMethodDef pyg_pid_methods[] = { static void pyg_pid_free(PyObject *gpid) { - g_spawn_close_pid((GPid) _PyLong_AsLong(gpid)); - _PyLong_Type.tp_free((void *) gpid); + g_spawn_close_pid((GPid) PYGLIB_PyLong_AsLong(gpid)); + PYGLIB_PyLong_Type.tp_free((void *) gpid); } static int @@ -64,14 +64,15 @@ pyg_pid_tp_init(PyObject *self, PyObject *args, PyObject *kwargs) PyObject * pyg_pid_new(GPid pid) { - _PyLongObject *pygpid; - pygpid = PyObject_NEW(_PyLongObject, &PyGPid_Type); + PYGLIB_PyLongObject *pygpid; #if PY_VERSION_HEX >= 0x03000000 -# warning "FIXME: figure out how to subclass long" + return PyObject_CallMethod((PyObject*)&PyGPid_Type, "__new__", "Oi", + &PyGPid_Type, pid); #else + pygpid = PyObject_NEW(PyIntObject, &PyGPid_Type); pygpid->ob_ival = pid; -#endif +#endif return (PyObject *) pygpid; } @@ -149,7 +150,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) argv = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyargv, i); - if (!_PyUnicode_Check(tmp)) { + if (!PYGLIB_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "first argument must be a sequence of strings"); @@ -157,7 +158,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) Py_XDECREF(tmp); return NULL; } - argv[i] = _PyUnicode_AsString(tmp); + argv[i] = PYGLIB_PyUnicode_AsString(tmp); Py_DECREF(tmp); } @@ -174,7 +175,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) envp = g_new0(char *, len + 1); for (i = 0; i < len; ++i) { PyObject *tmp = PySequence_ITEM(pyenvp, i); - if (!_PyUnicode_Check(tmp)) { + if (!PYGLIB_PyUnicode_Check(tmp)) { PyErr_SetString(PyExc_TypeError, "glib.spawn_async: " "second argument must be a sequence of strings"); @@ -183,7 +184,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) g_free(argv); return NULL; } - envp[i] = _PyUnicode_AsString(tmp); + envp[i] = PYGLIB_PyUnicode_AsString(tmp); Py_DECREF(tmp); } } @@ -228,21 +229,21 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) if (envp) g_free(envp); if (standard_input) - pystdin = _PyLong_FromLong(*standard_input); + pystdin = PYGLIB_PyLong_FromLong(*standard_input); else { Py_INCREF(Py_None); pystdin = Py_None; } if (standard_output) - pystdout = _PyLong_FromLong(*standard_output); + pystdout = PYGLIB_PyLong_FromLong(*standard_output); else { Py_INCREF(Py_None); pystdout = Py_None; } if (standard_error) - pystderr = _PyLong_FromLong(*standard_error); + pystderr = PYGLIB_PyLong_FromLong(*standard_error); else { Py_INCREF(Py_None); pystderr = Py_None; @@ -254,7 +255,7 @@ pyglib_spawn_async(PyObject *object, PyObject *args, PyObject *kwargs) void pyglib_spawn_register_types(PyObject *d) { - PyGPid_Type.tp_base = &_PyLong_Type; + PyGPid_Type.tp_base = &PYGLIB_PyLong_Type; PyGPid_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGPid_Type.tp_methods = pyg_pid_methods; PyGPid_Type.tp_init = pyg_pid_tp_init; diff --git a/gobject/Makefile.in b/gobject/Makefile.in index 7300152..b92611e 100644 --- a/gobject/Makefile.in +++ b/gobject/Makefile.in @@ -168,6 +168,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ diff --git a/gobject/__init__.py b/gobject/__init__.py index d5aec45..31e6bb0 100644 --- a/gobject/__init__.py +++ b/gobject/__init__.py @@ -29,7 +29,7 @@ from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \ filename_from_utf8, get_application_name, set_application_name, \ get_prgname, set_prgname, main_depth, Pid, GError, glib_version, \ MainLoop, MainContext, main_context_default, IOChannel, Source, Idle, \ - Timeout, PollFD, OptionGroup, OptionContext, option + Timeout, PollFD, OptionGroup, OptionContext, option, uri_list_extract_uris from glib import SPAWN_LEAVE_DESCRIPTORS_OPEN, SPAWN_DO_NOT_REAP_CHILD, \ SPAWN_SEARCH_PATH, SPAWN_STDOUT_TO_DEV_NULL, SPAWN_STDERR_TO_DEV_NULL, \ SPAWN_CHILD_INHERITS_STDIN, SPAWN_FILE_AND_ARGV_ZERO, PRIORITY_HIGH, \ diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 09244b8..4e9c07d 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -50,7 +50,7 @@ static gboolean log_handlers_disabled = FALSE; static void pyg_flags_add_constants(PyObject *module, GType flags_type, const gchar *strip_prefix); - + /* -------------- GDK threading hooks ---------------------------- */ /** @@ -109,14 +109,14 @@ pyg_type_name (PyObject *self, PyObject *args) "use GType.name instead")) return NULL; #endif - + if (!PyArg_ParseTuple(args, "O:gobject.type_name", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) return NULL; name = g_type_name(type); if (name) - return _PyUnicode_FromString(name); + return PYGLIB_PyUnicode_FromString(name); PyErr_SetString(PyExc_RuntimeError, "unknown typecode"); return NULL; } @@ -131,14 +131,14 @@ pyg_type_from_name (PyObject *self, PyObject *args) "gobject.type_from_name is deprecated; " "use GType.from_name instead")) return NULL; -#endif +#endif if (!PyArg_ParseTuple(args, "s:gobject.type_from_name", &name)) return NULL; type = _pyg_type_from_name(name); if (type != 0) return pyg_type_wrapper_new(type); PyErr_Format(PyExc_RuntimeError, "%s: unknown type name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -153,7 +153,7 @@ pyg_type_parent (PyObject *self, PyObject *args) "gobject.type_parent is deprecated; " "use GType.parent instead")) return NULL; -#endif +#endif if (!PyArg_ParseTuple(args, "O:gobject.type_parent", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -175,7 +175,7 @@ pyg_type_is_a (PyObject *self, PyObject *args) "gobject.type_is_a is deprecated; " "use GType.is_a instead")) return NULL; -#endif +#endif if (!PyArg_ParseTuple(args, "OO:gobject.type_is_a", >ype, &gparent)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -196,7 +196,7 @@ pyg_type_children (PyObject *self, PyObject *args) "gobject.type_children is deprecated; " "use GType.children instead")) return NULL; -#endif +#endif if (!PyArg_ParseTuple(args, "O:gobject.type_children", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -227,7 +227,7 @@ pyg_type_interfaces (PyObject *self, PyObject *args) "gobject.type_interfaces is deprecated; " "use GType.interfaces instead")) return NULL; -#endif +#endif if (!PyArg_ParseTuple(args, "O:gobject.type_interfaces", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -308,7 +308,7 @@ pyg_object_get_property (GObject *object, guint property_id, Py_DECREF(object_wrapper); Py_DECREF(py_pspec); Py_XDECREF(retval); - + pyglib_gil_state_release(state); } @@ -338,7 +338,7 @@ _pyg_signal_accumulator(GSignalInvocationHint *ihint, state = pyglib_gil_state_ensure(); if (ihint->detail) - py_detail = _PyUnicode_FromString(g_quark_to_string(ihint->detail)); + py_detail = PYGLIB_PyUnicode_FromString(g_quark_to_string(ihint->detail)); else { Py_INCREF(Py_None); py_detail = Py_None; @@ -497,17 +497,17 @@ add_signals (GType instance_type, PyObject *signals) const gchar *signal_name; gchar *signal_name_canon, *c; - if (!_PyUnicode_Check(key)) { + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "__gsignals__ keys must be strings"); ret = FALSE; break; } - signal_name = _PyUnicode_AsString (key); + signal_name = PYGLIB_PyUnicode_AsString (key); if (value == Py_None || - (_PyUnicode_Check(value) && - !strcmp(_PyUnicode_AsString(value), "override"))) + (PYGLIB_PyUnicode_Check(value) && + !strcmp(PYGLIB_PyUnicode_AsString(value), "override"))) { /* canonicalize signal name, replacing '-' with '_' */ signal_name_canon = g_strdup(signal_name); @@ -652,14 +652,14 @@ create_property (const gchar *prop_name, { gint default_value; PyObject *pydefault; - + if (!PyArg_ParseTuple(args, "O", &pydefault)) return NULL; - + if (pyg_enum_get_value(prop_type, pydefault, (gint *)&default_value)) return NULL; - + pspec = g_param_spec_enum (prop_name, nick, blurb, prop_type, default_value, flags); } @@ -671,11 +671,11 @@ create_property (const gchar *prop_name, if (!PyArg_ParseTuple(args, "O", &pydefault)) return NULL; - + if (pyg_flags_get_value(prop_type, pydefault, (gint *)&default_value)) return NULL; - + pspec = g_param_spec_flags (prop_name, nick, blurb, prop_type, default_value, flags); } @@ -745,7 +745,7 @@ create_property (const gchar *prop_name, PyErr_SetString(PyExc_TypeError, buf); return NULL; } - + return pspec; } @@ -764,27 +764,27 @@ pyg_param_spec_from_object (PyObject *tuple) PyErr_SetString(PyExc_TypeError, "paramspec tuples must be at least 4 elements long"); return NULL; - } + } slice = PySequence_GetSlice(tuple, 0, 4); if (!slice) { return NULL; } - + if (!PyArg_ParseTuple(slice, "sOzz", &prop_name, &py_prop_type, &nick, &blurb)) { Py_DECREF(slice); return NULL; } - + Py_DECREF(slice); - + prop_type = pyg_type_from_object(py_prop_type); if (!prop_type) { return NULL; } - + item = PyTuple_GetItem(tuple, val_length-1); - if (!_PyLong_Check(item)) { + if (!PYGLIB_PyLong_Check(item)) { PyErr_SetString(PyExc_TypeError, "last element in tuple must be an int"); return NULL; @@ -794,7 +794,7 @@ pyg_param_spec_from_object (PyObject *tuple) slice = PySequence_GetSlice(tuple, 4, val_length-1); pspec = create_property(prop_name, prop_type, nick, blurb, slice, - _PyLong_AsLong(item)); + PYGLIB_PyLong_AsLong(item)); return pspec; } @@ -816,16 +816,16 @@ add_properties (GType instance_type, PyObject *properties) gint val_length; PyObject *slice, *item, *py_prop_type; GParamSpec *pspec; - + /* values are of format (type,nick,blurb, type_specific_args, flags) */ - - if (!_PyUnicode_Check(key)) { + + if (!PYGLIB_PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "__gproperties__ keys must be strings"); ret = FALSE; break; } - prop_name = _PyUnicode_AsString (key); + prop_name = PYGLIB_PyUnicode_AsString (key); if (!PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, @@ -839,7 +839,7 @@ add_properties (GType instance_type, PyObject *properties) "__gproperties__ values must be at least 4 elements long"); ret = FALSE; break; - } + } slice = PySequence_GetSlice(value, 0, 3); if (!slice) { @@ -858,40 +858,40 @@ add_properties (GType instance_type, PyObject *properties) break; } item = PyTuple_GetItem(value, val_length-1); - if (!_PyLong_Check(item)) { + if (!PYGLIB_PyLong_Check(item)) { PyErr_SetString(PyExc_TypeError, "last element in __gproperties__ value tuple must be an int"); ret = FALSE; break; } - flags = _PyLong_AsLong(item); + flags = PYGLIB_PyLong_AsLong(item); /* slice is the extra items in the tuple */ slice = PySequence_GetSlice(value, 3, val_length-1); pspec = create_property(prop_name, prop_type, nick, blurb, slice, flags); Py_DECREF(slice); - + if (pspec) { g_object_class_install_property(oclass, 1, pspec); } else { PyObject *type, *value, *traceback; ret = FALSE; PyErr_Fetch(&type, &value, &traceback); - if (_PyUnicode_Check(value)) { + if (PYGLIB_PyUnicode_Check(value)) { char msg[256]; g_snprintf(msg, 256, "%s (while registering property '%s' for GType '%s')", - _PyUnicode_AsString(value), + PYGLIB_PyUnicode_AsString(value), prop_name, g_type_name(instance_type)); Py_DECREF(value); - value = _PyUnicode_FromString(msg); + value = PYGLIB_PyUnicode_FromString(msg); } PyErr_Restore(type, value, traceback); break; } } - + g_type_class_unref(oclass); return ret; } @@ -920,7 +920,7 @@ pyg_run_class_init(GType gtype, gpointer gclass, PyTypeObject *pyclass) if (rv) return rv; } - + list = g_type_get_qdata(gtype, pygobject_class_init_key); for (; list; list = list->next) { class_init = list->data; @@ -928,7 +928,7 @@ pyg_run_class_init(GType gtype, gpointer gclass, PyTypeObject *pyclass) if (rv) return rv; } - + return 0; } @@ -954,7 +954,7 @@ _wrap_pyg_type_register(PyObject *self, PyObject *args) if (pyg_type_register(class, type_name)) return NULL; } - + Py_INCREF(class); return (PyObject *) class; } @@ -966,17 +966,17 @@ get_type_name_for_class(PyTypeObject *class) char name_serial_str[16]; PyObject *module; char *type_name = NULL; - + /* make name for new GType */ name_serial = 1; /* give up after 1000 tries, just in case.. */ - while (name_serial < 1000) + while (name_serial < 1000) { g_free(type_name); snprintf(name_serial_str, 16, "-v%i", name_serial); module = PyObject_GetAttrString((PyObject *)class, "__module__"); - if (module && _PyUnicode_Check(module)) { - type_name = g_strconcat(_PyUnicode_AsString(module), ".", + if (module && PYGLIB_PyUnicode_Check(module)) { + type_name = g_strconcat(PYGLIB_PyUnicode_AsString(module), ".", class->tp_name, name_serial > 1 ? name_serial_str : NULL, NULL); @@ -1028,7 +1028,7 @@ pygobject__g_instance_init(GTypeInstance *instance, pygobject_has_updated_constructor_key)) return; - wrapper = g_object_get_qdata(object, pygobject_wrapper_key); + wrapper = g_object_get_qdata(object, pygobject_wrapper_key); if (wrapper == NULL) { wrapper = pygobject_init_wrapper_get(); if (wrapper && ((PyGObject *) wrapper)->obj == NULL) { @@ -1160,10 +1160,10 @@ pyg_type_register(PyTypeObject *class, const char *type_name) if (type_name) /* care is taken below not to free this */ - new_type_name = (gchar *) type_name; + new_type_name = (gchar *) type_name; else new_type_name = get_type_name_for_class(class); - + /* set class_data that will be passed to the class_init function. */ type_info.class_data = class; @@ -1192,7 +1192,7 @@ pyg_type_register(PyTypeObject *class, const char *type_name) /* set new value of __gtype__ on class */ gtype = pyg_type_wrapper_new(instance_type); - PyDict_SetItemString(class->tp_dict, "__gtype__", gtype); + PyObject_SetAttrString((PyObject *)class, "__gtype__", gtype); Py_DECREF(gtype); /* propagate new constructor API compatility flag from parent to child type */ @@ -1334,7 +1334,7 @@ pyg_signal_new(PyObject *self, PyObject *args) "argument 2 must be an object type or interface type"); return NULL; } - + return_type = pyg_type_from_object(py_return_type); if (!return_type) return NULL; @@ -1368,7 +1368,7 @@ pyg_signal_new(PyObject *self, PyObject *args) return_type, n_params, param_types); g_free(param_types); if (signal_id != 0) - return _PyLong_FromLong(signal_id); + return PYGLIB_PyLong_FromLong(signal_id); PyErr_SetString(PyExc_RuntimeError, "could not create signal"); return NULL; } @@ -1406,16 +1406,16 @@ pyg_signal_list_names (PyObject *self, PyObject *args, PyObject *kwargs) } else { iface = g_type_default_interface_ref(itype); } - + ids = g_signal_list_ids(itype, &n); list = PyTuple_New((gint)n); if (list != NULL) { for (i = 0; i < n; i++) PyTuple_SetItem(list, i, - _PyUnicode_FromString(g_signal_name(ids[i]))); + PYGLIB_PyUnicode_FromString(g_signal_name(ids[i]))); } - + g_free(ids); if (class) g_type_class_unref(class); @@ -1458,7 +1458,7 @@ pyg_signal_list_ids (PyObject *self, PyObject *args, PyObject *kwargs) } else { iface = g_type_default_interface_ref(itype); } - + ids = g_signal_list_ids(itype, &n); list = PyTuple_New((gint)n); @@ -1469,7 +1469,7 @@ pyg_signal_list_ids (PyObject *self, PyObject *args, PyObject *kwargs) } for (i = 0; i < n; i++) - PyTuple_SetItem(list, i, _PyLong_FromLong(ids[i])); + PyTuple_SetItem(list, i, PYGLIB_PyLong_FromLong(ids[i])); g_free(ids); if (class) g_type_class_unref(class); @@ -1510,14 +1510,14 @@ pyg_signal_lookup (PyObject *self, PyObject *args, PyObject *kwargs) } else { iface = g_type_default_interface_ref(itype); } - + id = g_signal_lookup(signal_name, itype); if (class) g_type_class_unref(class); else g_type_default_interface_unref(iface); - return _PyLong_FromLong(id); + return PYGLIB_PyLong_FromLong(id); } static PyObject * @@ -1532,7 +1532,7 @@ pyg_signal_name (PyObject *self, PyObject *args, PyObject *kwargs) return NULL; signal_name = g_signal_name(id); if (signal_name) - return _PyUnicode_FromString(signal_name); + return PYGLIB_PyUnicode_FromString(signal_name); Py_INCREF(Py_None); return Py_None; @@ -1582,7 +1582,7 @@ pyg_signal_query (PyObject *self, PyObject *args, PyObject *kwargs) "Usage: one of:\n" " gobject.signal_query(name, type)\n" " gobject.signal_query(signal_id)"); - + return NULL; } } @@ -1605,10 +1605,10 @@ pyg_signal_query (PyObject *self, PyObject *args, PyObject *kwargs) goto done; } - PyTuple_SET_ITEM(py_query, 0, _PyLong_FromLong(query.signal_id)); - PyTuple_SET_ITEM(py_query, 1, _PyUnicode_FromString(query.signal_name)); + PyTuple_SET_ITEM(py_query, 0, PYGLIB_PyLong_FromLong(query.signal_id)); + PyTuple_SET_ITEM(py_query, 1, PYGLIB_PyUnicode_FromString(query.signal_name)); PyTuple_SET_ITEM(py_query, 2, pyg_type_wrapper_new(query.itype)); - PyTuple_SET_ITEM(py_query, 3, _PyLong_FromLong(query.signal_flags)); + PyTuple_SET_ITEM(py_query, 3, PYGLIB_PyLong_FromLong(query.signal_flags)); PyTuple_SET_ITEM(py_query, 4, pyg_type_wrapper_new(query.return_type)); for (i = 0; i < query.n_params; i++) { PyTuple_SET_ITEM(params_list, i, @@ -1663,7 +1663,7 @@ pyg_object_class_list_properties (PyObject *self, PyObject *args) "type must be derived from GObject or an interface"); return NULL; } - + list = PyTuple_New(nprops); if (list == NULL) { g_free(specs); @@ -1719,7 +1719,7 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs) params = g_new0(GParameter, PyDict_Size(kwargs)); while (PyDict_Next (kwargs, &pos, &key, &value)) { GParamSpec *pspec; - const gchar *key_str = _PyUnicode_AsString (key); + const gchar *key_str = PYGLIB_PyUnicode_AsString (key); pspec = g_object_class_find_property (class, key_str); if (!pspec) { @@ -1754,7 +1754,7 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs) } g_free(params); g_type_class_unref(class); - + if (obj) { self = (PyGObject *) pygobject_new_full((GObject *)obj, FALSE, NULL); g_object_unref(obj); @@ -1785,7 +1785,7 @@ pyg_handler_marshal(gpointer user_data) res = PyObject_IsTrue(ret); Py_DECREF(ret); } - + pyglib_gil_state_release(state); return res; @@ -1808,7 +1808,7 @@ pyg_threads_init (PyObject *unused, PyObject *args, PyObject *kwargs) { if (!pyglib_enable_threads()) return NULL; - + Py_INCREF(Py_None); return Py_None; } @@ -1857,7 +1857,7 @@ marshal_emission_hook(GSignalInvocationHint *ihint, for (i = 0; i < n_param_values; i++) { PyObject *item = pyg_value_as_pyobject(¶m_values[i], FALSE); - + /* error condition */ if (!item) { goto out; @@ -1877,7 +1877,7 @@ marshal_emission_hook(GSignalInvocationHint *ihint, if (retobj == NULL) { PyErr_Print(); } - + retval = (retobj == Py_True ? TRUE : FALSE); Py_XDECREF(retobj); out: @@ -1910,7 +1910,7 @@ pyg_add_emission_hook(PyGObject *self, PyObject *args) return NULL; } Py_DECREF(first); - + if ((gtype = pyg_type_from_object(pygtype)) == 0) { return NULL; } @@ -1921,7 +1921,7 @@ pyg_add_emission_hook(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, gtype, &sigid, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1932,12 +1932,12 @@ pyg_add_emission_hook(PyGObject *self, PyObject *args) data = Py_BuildValue("(ON)", callback, extra_args); if (data == NULL) return NULL; - + hook_id = g_signal_add_emission_hook(sigid, detail, marshal_emission_hook, data, (GDestroyNotify)pyg_destroy_notify); - + return PyLong_FromUnsignedLong(hook_id); } @@ -1949,24 +1949,24 @@ pyg_remove_emission_hook(PyGObject *self, PyObject *args) guint signal_id; gulong hook_id; GType gtype; - + if (!PyArg_ParseTuple(args, "Osk:gobject.remove_emission_hook", &pygtype, &name, &hook_id)) return NULL; - + if ((gtype = pyg_type_from_object(pygtype)) == 0) { return NULL; } - + if (!g_signal_parse_name(name, gtype, &signal_id, NULL, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), - name); + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + name); return NULL; } g_signal_remove_emission_hook(signal_id, hook_id); - + Py_INCREF(Py_None); return Py_None; } @@ -2042,7 +2042,7 @@ pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix) { gint prefix_len; guint i; - + prefix_len = strlen(strip_prefix); /* Check so name starts with strip_prefix, if it doesn't: @@ -2162,7 +2162,7 @@ pyg_error_check(GError **error) "pyg_error_check is deprecated, use " "pyglib_error_check instead")) return NULL; -#endif +#endif return pyglib_error_check(error); } @@ -2187,7 +2187,7 @@ pyg_gerror_exception_check(GError **error) "pyg_gerror_exception_check is deprecated, use " "pyglib_gerror_exception_check instead")) return NULL; -#endif +#endif return pyglib_gerror_exception_check(error); } @@ -2202,9 +2202,9 @@ pyg_gerror_exception_check(GError **error) * arguments/properties * @nparams: output parameter to contain actual number of arguments found * @py_args: array of PyObject* containing the actual constructor arguments - * + * * Parses an array of PyObject's and creates a GParameter array - * + * * Return value: %TRUE if all is successful, otherwise %FALSE and * python exception set. **/ @@ -2298,9 +2298,9 @@ pygobject_construct(PyGObject *self, const char *first_property_name, ...) if (!pspec) { - g_warning("%s: object class `%s' has no property named `%s'", - G_STRFUNC, - g_type_name(object_type), + g_warning("%s: object class `%s' has no property named `%s'", + G_STRFUNC, + g_type_name(object_type), name); break; } @@ -2347,12 +2347,12 @@ pyg_integer_richcompare(PyObject *v, PyObject *w, int op) gboolean t; switch (op) { - case Py_EQ: t = _PyLong_AS_LONG(v) == _PyLong_AS_LONG(w); break; - case Py_NE: t = _PyLong_AS_LONG(v) != _PyLong_AS_LONG(w); break; - case Py_LE: t = _PyLong_AS_LONG(v) <= _PyLong_AS_LONG(w); break; - case Py_GE: t = _PyLong_AS_LONG(v) >= _PyLong_AS_LONG(w); break; - case Py_LT: t = _PyLong_AS_LONG(v) < _PyLong_AS_LONG(w); break; - case Py_GT: t = _PyLong_AS_LONG(v) > _PyLong_AS_LONG(w); break; + case Py_EQ: t = PYGLIB_PyLong_AS_LONG(v) == PYGLIB_PyLong_AS_LONG(w); break; + case Py_NE: t = PYGLIB_PyLong_AS_LONG(v) != PYGLIB_PyLong_AS_LONG(w); break; + case Py_LE: t = PYGLIB_PyLong_AS_LONG(v) <= PYGLIB_PyLong_AS_LONG(w); break; + case Py_GE: t = PYGLIB_PyLong_AS_LONG(v) >= PYGLIB_PyLong_AS_LONG(w); break; + case Py_LT: t = PYGLIB_PyLong_AS_LONG(v) < PYGLIB_PyLong_AS_LONG(w); break; + case Py_GT: t = PYGLIB_PyLong_AS_LONG(v) > PYGLIB_PyLong_AS_LONG(w); break; default: g_assert_not_reached(); } @@ -2380,7 +2380,7 @@ _log_func(const gchar *log_domain, } static void -add_warning_redirection(const char *domain, +add_warning_redirection(const char *domain, PyObject *warning) { g_return_if_fail(domain != NULL); @@ -2390,7 +2390,7 @@ add_warning_redirection(const char *domain, { guint handler; gpointer old_handler; - + if (!log_handlers) log_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); @@ -2415,7 +2415,7 @@ static void disable_warning_redirections(void) { log_handlers_disabled = TRUE; - + if (log_handlers) { g_hash_table_foreach(log_handlers, remove_handler, NULL); @@ -2457,7 +2457,7 @@ struct _PyGObject_Functions pygobject_api_functions = { pyg_enum_add_constants, pyg_flags_add_constants, - + pyg_constant_strip_prefix, pyg_error_check, @@ -2478,7 +2478,7 @@ struct _PyGObject_Functions pygobject_api_functions = { &PyGEnum_Type, pyg_enum_add, pyg_enum_from_gtype, - + &PyGFlags_Type, pyg_flags_add, pyg_flags_from_gtype, @@ -2494,15 +2494,15 @@ struct _PyGObject_Functions pygobject_api_functions = { pygobject_constructv, pygobject_construct, pyg_set_object_has_new_constructor, - + add_warning_redirection, disable_warning_redirections, - + pyg_type_register_custom_callback, pyg_gerror_exception_check, pyglib_option_group_new - + }; /* for addon libraries ... */ @@ -2510,7 +2510,7 @@ static void pygobject_register_api(PyObject *d) { PyObject *api; - + api = PyCObject_FromVoidPtr(&pygobject_api_functions,NULL); PyDict_SetItemString(d, "_PyGObject_API", api); Py_DECREF(api); @@ -2548,8 +2548,8 @@ pygobject_register_constants(PyObject *m) PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromUnsignedLongLong(G_MAXSIZE)); PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromUnsignedLongLong(G_MAXSSIZE)); #elif PY_VERSION_HEX < 0x02060000 /* 2.5 */ - PyModule_AddObject(m, "G_MAXSIZE", _PyLong_FromSize_t(G_MAXSIZE)); - PyModule_AddObject(m, "G_MAXSSIZE", _PyLong_FromSsize_t(G_MAXSSIZE)); + PyModule_AddObject(m, "G_MAXSIZE", PYGLIB_PyLong_FromSize_t(G_MAXSIZE)); + PyModule_AddObject(m, "G_MAXSSIZE", PYGLIB_PyLong_FromSsize_t(G_MAXSSIZE)); #else /* 2.6+ */ PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromSize_t(G_MAXSIZE)); PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromSsize_t(G_MAXSSIZE)); @@ -2588,7 +2588,7 @@ static void pygobject_register_features(PyObject *d) { PyObject *features; - + features = PyDict_New(); #ifdef HAVE_FFI_H PyDict_SetItemString(features, "generic-c-marshaller", Py_True); @@ -2648,7 +2648,7 @@ PYGLIB_MODULE_START(_gobject, "gobject._gobject") pygobject_pointer_register_types(d); pygobject_enum_register_types(d); pygobject_flags_register_types(d); - + /* signal registration recognizes this special accumulator 'constant' */ _pyg_signal_accumulator_true_handled_func = \ PyDict_GetItemString(d, "signal_accumulator_true_handled"); diff --git a/gobject/propertyhelper.py b/gobject/propertyhelper.py index e299273..2f77a4d 100644 --- a/gobject/propertyhelper.py +++ b/gobject/propertyhelper.py @@ -36,6 +36,12 @@ from gobject.constants import \ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \ G_MAXULONG +if sys.version_info >= (3, 0): + _basestring = str + _long = int +else: + _basestring = basestring + _long = long class property(object): """ @@ -107,11 +113,11 @@ class property(object): self.default = self._get_default(default) self._check_default() - if not isinstance(nick, basestring): + if not isinstance(nick, _basestring): raise TypeError("nick must be a string") self.nick = nick - if not isinstance(blurb, basestring): + if not isinstance(blurb, _basestring): raise TypeError("blurb must be a string") self.blurb = blurb @@ -171,12 +177,12 @@ class property(object): raise exc def _type_from_python(self, type): - if type == int: + if type == _long: + return TYPE_LONG + elif type == int: return TYPE_INT elif type == bool: return TYPE_BOOLEAN - elif type == long: - return TYPE_LONG elif type == float: return TYPE_DOUBLE elif type == str: diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c index 7bc8e8e..a00386b 100644 --- a/gobject/pygboxed.c +++ b/gobject/pygboxed.c @@ -47,14 +47,20 @@ pyg_boxed_dealloc(PyGBoxed *self) Py_TYPE(self)->tp_free((PyObject *)self); } -static int -pyg_boxed_compare(PyGBoxed *self, PyGBoxed *v) +static PyObject* +pyg_boxed_richcompare(PyObject *self, PyObject *other, int op) { - if (self->boxed == v->boxed) return 0; - if (self->boxed > v->boxed) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGBoxed_Type) + return _pyglib_generic_ptr_richcompare(((PyGBoxed*)self)->boxed, + ((PyGBoxed*)other)->boxed, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } + static long pyg_boxed_hash(PyGBoxed *self) { @@ -68,7 +74,7 @@ pyg_boxed_repr(PyGBoxed *self) g_snprintf(buf, sizeof(buf), "<%s at 0x%lx>", g_type_name(self->gtype), (long)self->boxed); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static int @@ -216,7 +222,7 @@ pygobject_boxed_register_types(PyObject *d) pygboxed_marshal_key = g_quark_from_static_string("PyGBoxed::marshal"); PyGBoxed_Type.tp_dealloc = (destructor)pyg_boxed_dealloc; - PyGBoxed_Type.tp_compare = (cmpfunc)pyg_boxed_compare; + PyGBoxed_Type.tp_richcompare = pyg_boxed_richcompare; PyGBoxed_Type.tp_repr = (reprfunc)pyg_boxed_repr; PyGBoxed_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGBoxed_Type.tp_methods = pygboxed_methods; diff --git a/gobject/pygenum.c b/gobject/pygenum.c index a09ab98..c0a51a9 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -34,12 +34,29 @@ GQuark pygenum_class_key; PYGLIB_DEFINE_TYPE("gobject.GEnum", PyGEnum_Type, PyGEnum); +static PyObject * +pyg_enum_val_new(PyObject* subclass, GType gtype, PyObject *intval) +{ + PyObject *item; + +#if PY_VERSION_HEX >= 0x03000000 + item = PyObject_CallMethod((PyObject*)&PyLong_Type, "__new__", "OO", + subclass, intval); +#else + item = ((PyTypeObject *)subclass)->tp_alloc((PyTypeObject *)subclass, 0); + ((PyIntObject*)item)->ob_ival = PyInt_AS_LONG(intval); +#endif + ((PyGEnum*)item)->gtype = gtype; + + return item; +} + static PyObject * pyg_enum_richcompare(PyGEnum *self, PyObject *other, int op) { static char warning[256]; - if (!_PyLong_Check(other)) { + if (!PYGLIB_PyLong_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } @@ -61,22 +78,25 @@ pyg_enum_repr(PyGEnum *self) const char *value; guint index; static char tmp[256]; - + long l; + enum_class = g_type_class_ref(self->gtype); g_assert(G_IS_ENUM_CLASS(enum_class)); - for (index = 0; index < enum_class->n_values; index++) - if (_PyLong_AS_LONG(self) == enum_class->values[index].value) + l = PYGLIB_PyLong_AS_LONG(self); + for (index = 0; index < enum_class->n_values; index++) + if (l == enum_class->values[index].value) break; + value = enum_class->values[index].value_name; if (value) sprintf(tmp, "", value, g_type_name(self->gtype)); else - sprintf(tmp, "", _PyLong_AS_LONG(self), g_type_name(self->gtype)); + sprintf(tmp, "", PYGLIB_PyLong_AS_LONG(self), g_type_name(self->gtype)); g_type_class_unref(enum_class); - return _PyUnicode_FromString(tmp); + return PYGLIB_PyUnicode_FromString(tmp); } static PyObject * @@ -90,18 +110,18 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "l", kwlist, &value)) return NULL; - + pytc = PyObject_GetAttrString((PyObject *)type, "__gtype__"); if (!pytc) return NULL; - + if (!PyObject_TypeCheck(pytc, &PyGTypeWrapper_Type)) { Py_DECREF(pytc); PyErr_SetString(PyExc_TypeError, "__gtype__ attribute not a typecode"); return NULL; } - + gtype = pyg_type_from_object(pytc); Py_DECREF(pytc); @@ -133,8 +153,8 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } g_type_class_unref(eclass); - - intvalue = _PyLong_FromLong(value); + + intvalue = PYGLIB_PyLong_FromLong(value); ret = PyDict_GetItem(values, intvalue); Py_DECREF(intvalue); Py_DECREF(values); @@ -142,7 +162,7 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) Py_INCREF(ret); else PyErr_Format(PyExc_ValueError, "invalid enum value: %ld", value); - + return ret; } @@ -164,28 +184,21 @@ pyg_enum_from_gtype (GType gtype, int value) if (!pyclass) pyclass = pyg_enum_add(NULL, g_type_name(gtype), NULL, gtype); if (!pyclass) - return _PyLong_FromLong(value); - + return PYGLIB_PyLong_FromLong(value); + values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict, "__enum_values__"); - intvalue = _PyLong_FromLong(value); + intvalue = PYGLIB_PyLong_FromLong(value); retval = PyDict_GetItem(values, intvalue); - Py_DECREF(intvalue); - if (!retval) { + if (retval) { + Py_INCREF(retval); + } + else { PyErr_Clear(); - retval = ((PyTypeObject *)pyclass)->tp_alloc((PyTypeObject *)pyclass, 0); - g_assert(retval != NULL); - -#if PY_VERSION_HEX >= 0x03000000 -# warning "FIXME: figure out how to subclass long" -#else - ((_PyLongObject*)retval)->ob_ival = value; -#endif - ((PyGFlags*)retval)->gtype = gtype; - //return _PyLong_FromLong(value); + retval = pyg_enum_val_new(pyclass, gtype, intvalue); } - - Py_INCREF(retval); + Py_DECREF(intvalue); + return retval; } @@ -199,14 +212,14 @@ pyg_enum_add (PyObject * module, PyObject *instance_dict, *stub, *values, *o; GEnumClass *eclass; int i; - + g_return_val_if_fail(typename != NULL, NULL); if (!g_type_is_a(gtype, G_TYPE_ENUM)) { g_warning("Trying to register gtype '%s' as enum when in fact it is of type '%s'", g_type_name(gtype), g_type_name(G_TYPE_FUNDAMENTAL(gtype))); return NULL; } - + state = pyglib_gil_state_ensure(); instance_dict = PyDict_New(); @@ -226,8 +239,8 @@ pyg_enum_add (PyObject * module, if (module) PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__module__", - _PyUnicode_FromString(PyModule_GetName(module))); - + PYGLIB_PyUnicode_FromString(PyModule_GetName(module))); + g_type_set_qdata(gtype, pygenum_class_key, stub); o = pyg_type_wrapper_new(gtype); @@ -247,18 +260,11 @@ pyg_enum_add (PyObject * module, for (i = 0; i < eclass->n_values; i++) { PyObject *item, *intval; - item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0); -#if PY_VERSION_HEX >= 0x03000000 -# warning "FIXME: figure out how to subclass long" -#else - ((_PyLongObject*)item)->ob_ival = eclass->values[i].value; -#endif - ((PyGEnum*)item)->gtype = gtype; - - intval = _PyLong_FromLong(eclass->values[i].value); + intval = PYGLIB_PyLong_FromLong(eclass->values[i].value); + item = pyg_enum_val_new(stub, gtype, intval); PyDict_SetItem(values, intval, item); Py_DECREF(intval); - + if (module) { char *prefix; @@ -269,13 +275,13 @@ pyg_enum_add (PyObject * module, Py_INCREF(item); } } - + PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__enum_values__", values); Py_DECREF(values); g_type_class_unref(eclass); - + pyglib_gil_state_release(state); return stub; } @@ -286,7 +292,7 @@ pyg_enum_reduce(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, ":GEnum.__reduce__")) return NULL; - return Py_BuildValue("(O(i)O)", Py_TYPE(self), _PyLong_AsLong(self), + return Py_BuildValue("(O(i)O)", Py_TYPE(self), PYGLIB_PyLong_AsLong(self), PyObject_GetAttrString(self, "__dict__")); } @@ -296,13 +302,13 @@ pyg_enum_get_value_name(PyGEnum *self, void *closure) GEnumClass *enum_class; GEnumValue *enum_value; PyObject *retval; - + enum_class = g_type_class_ref(self->gtype); g_assert(G_IS_ENUM_CLASS(enum_class)); - - enum_value = g_enum_get_value(enum_class, _PyLong_AS_LONG(self)); - retval = _PyUnicode_FromString(enum_value->value_name); + enum_value = g_enum_get_value(enum_class, PYGLIB_PyLong_AS_LONG(self)); + + retval = PYGLIB_PyUnicode_FromString(enum_value->value_name); g_type_class_unref(enum_class); return retval; @@ -314,13 +320,13 @@ pyg_enum_get_value_nick(PyGEnum *self, void *closure) GEnumClass *enum_class; GEnumValue *enum_value; PyObject *retval; - + enum_class = g_type_class_ref(self->gtype); g_assert(G_IS_ENUM_CLASS(enum_class)); - - enum_value = g_enum_get_value(enum_class, _PyLong_AS_LONG(self)); - retval = _PyUnicode_FromString(enum_value->value_nick); + enum_value = g_enum_get_value(enum_class, PYGLIB_PyLong_AS_LONG(self)); + + retval = PYGLIB_PyUnicode_FromString(enum_value->value_nick); g_type_class_unref(enum_class); return retval; @@ -343,14 +349,18 @@ pygobject_enum_register_types(PyObject *d) { pygenum_class_key = g_quark_from_static_string("PyGEnum::class"); - PyGEnum_Type.tp_base = &_PyLong_Type; + PyGEnum_Type.tp_base = &PYGLIB_PyLong_Type; +#if PY_VERSION_HEX < 0x03000000 + PyGEnum_Type.tp_new = pyg_enum_new; +#else + PyGEnum_Type.tp_new = PyLong_Type.tp_new; + PyGEnum_Type.tp_hash = PyLong_Type.tp_hash; +#endif PyGEnum_Type.tp_repr = (reprfunc)pyg_enum_repr; PyGEnum_Type.tp_str = (reprfunc)pyg_enum_repr; PyGEnum_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGEnum_Type.tp_richcompare = (richcmpfunc)pyg_enum_richcompare; PyGEnum_Type.tp_methods = pyg_enum_methods; PyGEnum_Type.tp_getset = pyg_enum_getsets; - PyGEnum_Type.tp_new = pyg_enum_new; PYGOBJECT_REGISTER_GTYPE(d, PyGEnum_Type, "GEnum", G_TYPE_ENUM); - } diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 7bcd294..936f314 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -35,12 +35,29 @@ GQuark pygflags_class_key; PYGLIB_DEFINE_TYPE("gobject.GFlags", PyGFlags_Type, PyGFlags); +static PyObject * +pyg_flags_val_new(PyObject* subclass, GType gtype, PyObject *intval) +{ + PyObject *item; + +#if PY_VERSION_HEX >= 0x03000000 + item = PyObject_CallMethod((PyObject*)&PyLong_Type, "__new__", "OO", + subclass, intval); +#else + item = ((PyTypeObject *)subclass)->tp_alloc((PyTypeObject *)subclass, 0); + ((PyIntObject*)item)->ob_ival = PyInt_AS_LONG(intval); +#endif + ((PyGFlags*)item)->gtype = gtype; + + return item; +} + static PyObject * pyg_flags_richcompare(PyGFlags *self, PyObject *other, int op) { static char warning[256]; - if (!_PyLong_Check(other)) { + if (!PYGLIB_PyLong_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } @@ -64,7 +81,7 @@ generate_repr(GType gtype, int value) flags_class = g_type_class_ref(gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); - + for (i = 0; i < flags_class->n_values; i++) { /* Some types (eg GstElementState in GStreamer 0.8) has flags with 0 values, * we're just ignore them for now otherwise they'll always show up @@ -82,31 +99,31 @@ generate_repr(GType gtype, int value) } } } - + g_type_class_unref(flags_class); return retval; } - + static PyObject * pyg_flags_repr(PyGFlags *self) { char *tmp, *retval; PyObject *pyretval; - - tmp = generate_repr(self->gtype, _PyLong_AS_LONG(self)); + + tmp = generate_repr(self->gtype, PYGLIB_PyLong_AS_LONG(self)); if (tmp) retval = g_strdup_printf("", tmp, g_type_name(self->gtype)); else - retval = g_strdup_printf("", _PyLong_AS_LONG(self), + retval = g_strdup_printf("", PYGLIB_PyLong_AS_LONG(self), g_type_name(self->gtype)); g_free(tmp); - - pyretval = _PyUnicode_FromString(retval); + + pyretval = PYGLIB_PyUnicode_FromString(retval); g_free(retval); - + return pyretval; } @@ -118,21 +135,21 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *pytc, *values, *ret, *pyint; GType gtype; GFlagsClass *eclass; - + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "l", kwlist, &value)) return NULL; - + pytc = PyObject_GetAttrString((PyObject *)type, "__gtype__"); if (!pytc) return NULL; - + if (!PyObject_TypeCheck(pytc, &PyGTypeWrapper_Type)) { Py_DECREF(pytc); PyErr_SetString(PyExc_TypeError, "__gtype__ attribute not a typecode"); return NULL; } - + gtype = pyg_type_from_object(pytc); Py_DECREF(pytc); @@ -143,7 +160,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) g_type_class_unref(eclass); return NULL; } - + if (!PyDict_Check(values) || PyDict_Size(values) != eclass->n_values) { PyErr_SetString(PyExc_TypeError, "__flags_values__ badly formed"); Py_DECREF(values); @@ -152,8 +169,8 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } g_type_class_unref(eclass); - - pyint = _PyLong_FromLong(value); + + pyint = PYGLIB_PyLong_FromLong(value); ret = PyDict_GetItem(values, pyint); Py_DECREF(pyint); Py_DECREF(values); @@ -171,7 +188,7 @@ pyg_flags_from_gtype (GType gtype, int value) PyObject *pyclass, *values, *retval, *pyint; g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL); - + /* Get a wrapper class by: * 1. check for one attached to the gtype * 2. lookup one in a typelib @@ -183,29 +200,22 @@ pyg_flags_from_gtype (GType gtype, int value) if (!pyclass) pyclass = pyg_flags_add(NULL, g_type_name(gtype), NULL, gtype); if (!pyclass) - return _PyLong_FromLong(value); - + return PYGLIB_PyLong_FromLong(value); + values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict, "__flags_values__"); - pyint = _PyLong_FromLong(value); + pyint = PYGLIB_PyLong_FromLong(value); retval = PyDict_GetItem(values, pyint); - Py_DECREF(pyint); - if (!retval) { PyErr_Clear(); - retval = ((PyTypeObject *)pyclass)->tp_alloc((PyTypeObject *)pyclass, 0); + retval = pyg_flags_val_new(pyclass, gtype, pyint); g_assert(retval != NULL); - -#if PY_VERSION_HEX >= 0x03000000 -# warning "FIXME: figure out how to subclass long" -#else - ((_PyLongObject*)retval)->ob_ival = value; -#endif - ((PyGFlags*)retval)->gtype = gtype; } else { Py_INCREF(retval); } + Py_DECREF(pyint); + return retval; } @@ -226,7 +236,7 @@ pyg_flags_add (PyObject * module, g_type_name(gtype), g_type_name(G_TYPE_FUNDAMENTAL(gtype))); return NULL; } - + state = pyglib_gil_state_ensure(); instance_dict = PyDict_New(); @@ -239,15 +249,15 @@ pyg_flags_add (PyObject * module, pyglib_gil_state_release(state); return NULL; } - + ((PyTypeObject *)stub)->tp_flags &= ~Py_TPFLAGS_BASETYPE; ((PyTypeObject *)stub)->tp_new = pyg_flags_new; if (module) { PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__module__", - _PyUnicode_FromString(PyModule_GetName(module))); - + PYGLIB_PyUnicode_FromString(PyModule_GetName(module))); + /* Add it to the module name space */ PyModule_AddObject(module, (char*)typename, stub); Py_INCREF(stub); @@ -257,7 +267,7 @@ pyg_flags_add (PyObject * module, o = pyg_type_wrapper_new(gtype); PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__gtype__", o); Py_DECREF(o); - + /* Register flag values */ eclass = G_FLAGS_CLASS(g_type_class_ref(gtype)); @@ -265,29 +275,22 @@ pyg_flags_add (PyObject * module, for (i = 0; i < eclass->n_values; i++) { PyObject *item, *intval; - item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0); -#if PY_VERSION_HEX >= 0x03000000 -# warning "FIXME: figure out how to subclass long" -#else - ((_PyLongObject*)item)->ob_ival = eclass->values[i].value; -#endif - ((PyGFlags*)item)->gtype = gtype; - - intval = _PyLong_FromLong(eclass->values[i].value); + intval = PYGLIB_PyLong_FromLong(eclass->values[i].value); + item = pyg_flags_val_new(stub, gtype, intval); PyDict_SetItem(values, intval, item); Py_DECREF(intval); if (module) { char *prefix; - + prefix = g_strdup(pyg_constant_strip_prefix(eclass->values[i].value_name, strip_prefix)); + Py_INCREF(item); PyModule_AddObject(module, prefix, item); g_free(prefix); - - Py_INCREF(item); } + Py_DECREF(item); } - + PyDict_SetItemString(((PyTypeObject *)stub)->tp_dict, "__flags_values__", values); Py_DECREF(values); @@ -303,32 +306,32 @@ static PyObject * pyg_flags_and(PyGFlags *a, PyGFlags *b) { if (!PyGFlags_Check(a) || !PyGFlags_Check(b)) - return _PyLong_Type.tp_as_number->nb_and((PyObject*)a, + return PYGLIB_PyLong_Type.tp_as_number->nb_and((PyObject*)a, (PyObject*)b); - + return pyg_flags_from_gtype(a->gtype, - _PyLong_AS_LONG(a) & _PyLong_AS_LONG(b)); + PYGLIB_PyLong_AS_LONG(a) & PYGLIB_PyLong_AS_LONG(b)); } static PyObject * pyg_flags_or(PyGFlags *a, PyGFlags *b) { if (!PyGFlags_Check(a) || !PyGFlags_Check(b)) - return _PyLong_Type.tp_as_number->nb_or((PyObject*)a, + return PYGLIB_PyLong_Type.tp_as_number->nb_or((PyObject*)a, (PyObject*)b); - return pyg_flags_from_gtype(a->gtype, _PyLong_AS_LONG(a) | _PyLong_AS_LONG(b)); + return pyg_flags_from_gtype(a->gtype, PYGLIB_PyLong_AS_LONG(a) | PYGLIB_PyLong_AS_LONG(b)); } static PyObject * pyg_flags_xor(PyGFlags *a, PyGFlags *b) { if (!PyGFlags_Check(a) || !PyGFlags_Check(b)) - return _PyLong_Type.tp_as_number->nb_xor((PyObject*)a, + return PYGLIB_PyLong_Type.tp_as_number->nb_xor((PyObject*)a, (PyObject*)b); return pyg_flags_from_gtype(a->gtype, - _PyLong_AS_LONG(a) ^ _PyLong_AS_LONG(b)); + PYGLIB_PyLong_AS_LONG(a) ^ PYGLIB_PyLong_AS_LONG(b)); } @@ -348,12 +351,12 @@ pyg_flags_get_first_value_name(PyGFlags *self, void *closure) GFlagsClass *flags_class; GFlagsValue *flags_value; PyObject *retval; - + flags_class = g_type_class_ref(self->gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); - flags_value = g_flags_get_first_value(flags_class, _PyLong_AS_LONG(self)); + flags_value = g_flags_get_first_value(flags_class, PYGLIB_PyLong_AS_LONG(self)); if (flags_value) - retval = _PyUnicode_FromString(flags_value->value_name); + retval = PYGLIB_PyUnicode_FromString(flags_value->value_name); else { retval = Py_None; Py_INCREF(Py_None); @@ -369,13 +372,13 @@ pyg_flags_get_first_value_nick(PyGFlags *self, void *closure) GFlagsClass *flags_class; GFlagsValue *flags_value; PyObject *retval; - + flags_class = g_type_class_ref(self->gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); - flags_value = g_flags_get_first_value(flags_class, _PyLong_AS_LONG(self)); + flags_value = g_flags_get_first_value(flags_class, PYGLIB_PyLong_AS_LONG(self)); if (flags_value) - retval = _PyUnicode_FromString(flags_value->value_nick); + retval = PYGLIB_PyUnicode_FromString(flags_value->value_nick); else { retval = Py_None; Py_INCREF(Py_None); @@ -391,14 +394,14 @@ pyg_flags_get_value_names(PyGFlags *self, void *closure) GFlagsClass *flags_class; PyObject *retval; int i; - + flags_class = g_type_class_ref(self->gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); - + retval = PyList_New(0); for (i = 0; i < flags_class->n_values; i++) - if ((_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) - PyList_Append(retval, _PyUnicode_FromString(flags_class->values[i].value_name)); + if ((PYGLIB_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) + PyList_Append(retval, PYGLIB_PyUnicode_FromString(flags_class->values[i].value_name)); g_type_class_unref(flags_class); @@ -411,14 +414,14 @@ pyg_flags_get_value_nicks(PyGFlags *self, void *closure) GFlagsClass *flags_class; PyObject *retval; int i; - + flags_class = g_type_class_ref(self->gtype); g_assert(G_IS_FLAGS_CLASS(flags_class)); - + retval = PyList_New(0); for (i = 0; i < flags_class->n_values; i++) - if ((_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) - PyList_Append(retval, _PyUnicode_FromString(flags_class->values[i].value_nick)); + if ((PYGLIB_PyLong_AS_LONG(self) & flags_class->values[i].value) == flags_class->values[i].value) + PyList_Append(retval, PYGLIB_PyUnicode_FromString(flags_class->values[i].value_nick)); g_type_class_unref(flags_class); @@ -439,7 +442,9 @@ static PyNumberMethods pyg_flags_as_number = { (binaryfunc)pyg_flags_warn, /* nb_multiply */ (binaryfunc)pyg_flags_warn, /* nb_divide */ (binaryfunc)pyg_flags_warn, /* nb_remainder */ - (binaryfunc)pyg_flags_warn, /* nb_divmod */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)pyg_flags_warn, /* nb_divmod */ +#endif (ternaryfunc)pyg_flags_warn, /* nb_power */ 0, /* nb_negative */ 0, /* nb_positive */ @@ -451,27 +456,6 @@ static PyNumberMethods pyg_flags_as_number = { (binaryfunc)pyg_flags_and, /* nb_and */ (binaryfunc)pyg_flags_xor, /* nb_xor */ (binaryfunc)pyg_flags_or, /* nb_or */ - 0, /* nb_coerce */ - 0, /* nb_int */ - 0, /* nb_long */ - 0, /* nb_float */ - 0, /* nb_oct */ - 0, /* nb_hex */ - 0, /* nb_inplace_add */ - 0, /* nb_inplace_subtract */ - 0, /* nb_inplace_multiply */ - 0, /* nb_inplace_divide */ - 0, /* nb_inplace_remainder */ - 0, /* nb_inplace_power */ - 0, /* nb_inplace_lshift */ - 0, /* nb_inplace_rshift */ - 0, /* nb_inplace_and */ - 0, /* nb_inplace_xor */ - 0, /* nb_inplace_or */ - 0, /* nb_floor_divide */ - 0, /* nb_true_divide */ - 0, /* nb_inplace_floor_divide */ - 0, /* nb_inplace_true_divide */ }; void @@ -479,13 +463,18 @@ pygobject_flags_register_types(PyObject *d) { pygflags_class_key = g_quark_from_static_string("PyGFlags::class"); - PyGFlags_Type.tp_base = &_PyLong_Type; + PyGFlags_Type.tp_base = &PYGLIB_PyLong_Type; +#if PY_VERSION_HEX < 0x03000000 + PyGFlags_Type.tp_new = pyg_flags_new; +#else + PyGFlags_Type.tp_new = PyLong_Type.tp_new; + PyGFlags_Type.tp_hash = PyLong_Type.tp_hash; +#endif PyGFlags_Type.tp_repr = (reprfunc)pyg_flags_repr; PyGFlags_Type.tp_as_number = &pyg_flags_as_number; PyGFlags_Type.tp_str = (reprfunc)pyg_flags_repr; PyGFlags_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; PyGFlags_Type.tp_richcompare = (richcmpfunc)pyg_flags_richcompare; PyGFlags_Type.tp_getset = pyg_flags_getsets; - PyGFlags_Type.tp_new = pyg_flags_new; PYGOBJECT_REGISTER_GTYPE(d, PyGFlags_Type, "GFlags", G_TYPE_FLAGS); } diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h index 2a09eed..26cb5f2 100644 --- a/gobject/pygobject-private.h +++ b/gobject/pygobject-private.h @@ -113,10 +113,10 @@ void pyg_register_gtype_custom(GType gtype, int pyg_value_from_pyobject(GValue *value, PyObject *obj); PyObject *pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed); int pyg_param_gvalue_from_pyobject(GValue* value, - PyObject* py_obj, + PyObject* py_obj, const GParamSpec* pspec); PyObject *pyg_param_gvalue_as_pyobject(const GValue* gvalue, - gboolean copy_boxed, + gboolean copy_boxed, const GParamSpec* pspec); GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data); @@ -175,14 +175,14 @@ const gchar * pyg_constant_strip_prefix(const gchar *name, const gchar *strip_pr /* pygflags */ typedef struct { - _PyLongObject parent; + PYGLIB_PyLongObject parent; GType gtype; } PyGFlags; extern PyTypeObject PyGFlags_Type; #define PyGFlags_Check(x) (g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_FLAGS)) - + extern PyObject * pyg_flags_add (PyObject * module, const char * type_name, const char * strip_prefix, @@ -194,7 +194,7 @@ extern PyObject * pyg_flags_from_gtype (GType gtype, #define PyGEnum_Check(x) (g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_ENUM)) typedef struct { - _PyLongObject parent; + PYGLIB_PyLongObject parent; GType gtype; } PyGEnum; @@ -221,7 +221,7 @@ extern PyTypeObject PyGObjectWeakRef_Type; static inline PyGObjectData * pyg_object_peek_inst_data(GObject *obj) { - return ((PyGObjectData *) + return ((PyGObjectData *) g_object_get_qdata(obj, pygobject_instance_data_key)); } diff --git a/gobject/pygobject.c b/gobject/pygobject.c index c37c8a8..eee3963 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -255,7 +255,7 @@ build_parameter_list(GObjectClass *class) name = g_strdup(g_param_spec_get_name(props[i])); /* hyphens cannot belong in identifiers */ g_strdelimit(name, "-", '_'); - prop_str = _PyUnicode_FromString(name); + prop_str = PYGLIB_PyUnicode_FromString(name); PyList_SetItem(props_list, i, prop_str); g_free(name); @@ -276,7 +276,7 @@ PyGProps_getattro(PyGProps *self, PyObject *attr) GValue value = { 0, }; PyObject *ret; - attr_name = _PyUnicode_AsString(attr); + attr_name = PYGLIB_PyUnicode_AsString(attr); if (!attr_name) { PyErr_Clear(); return PyObject_GenericGetAttr((PyObject *)self, attr); @@ -288,6 +288,12 @@ PyGProps_getattro(PyGProps *self, PyObject *attr) return build_parameter_list(class); } + if (self->pygobject != NULL) { + ret = pygi_get_property_value (self->pygobject, attr_name); + if (ret != NULL) + return ret; + } + pspec = g_object_class_find_property(class, attr_name); g_type_class_unref(class); @@ -361,6 +367,7 @@ PyGProps_setattro(PyGProps *self, PyObject *attr, PyObject *pvalue) GParamSpec *pspec; char *attr_name; GObject *obj; + int ret = -1; if (pvalue == NULL) { PyErr_SetString(PyExc_TypeError, "properties cannot be " @@ -368,7 +375,7 @@ PyGProps_setattro(PyGProps *self, PyObject *attr, PyObject *pvalue) return -1; } - attr_name = _PyUnicode_AsString(attr); + attr_name = PYGLIB_PyUnicode_AsString(attr); if (!attr_name) { PyErr_Clear(); return PyObject_GenericSetAttr((PyObject *)self, attr, pvalue); @@ -380,6 +387,13 @@ PyGProps_setattro(PyGProps *self, PyObject *attr, PyObject *pvalue) return -1; } + ret = pygi_set_property_value (self->pygobject, attr_name, pvalue); + if (ret == 0) + return 0; + else if (ret == -1) + if (PyErr_Occurred()) + return -1; + obj = self->pygobject->obj; pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj), attr_name); if (!pspec) { @@ -540,7 +554,7 @@ pygobject_register_class(PyObject *dict, const gchar *type_name, */ s = strrchr(type->tp_name, '.'); if (s != NULL) { - mod_name = _PyUnicode_FromStringAndSize(type->tp_name, (int)(s - type->tp_name)); + mod_name = PYGLIB_PyUnicode_FromStringAndSize(type->tp_name, (int)(s - type->tp_name)); PyDict_SetItemString(type->tp_dict, "__module__", mod_name); Py_DECREF(mod_name); } @@ -795,12 +809,15 @@ static void pygobject_inherit_slots(PyTypeObject *type, PyObject *bases, gboolean check_for_present) { static int slot_offsets[] = { offsetof(PyTypeObject, tp_richcompare), - offsetof(PyTypeObject, tp_compare), - offsetof(PyTypeObject, tp_hash), - offsetof(PyTypeObject, tp_iter), - offsetof(PyTypeObject, tp_repr), - offsetof(PyTypeObject, tp_str), - offsetof(PyTypeObject, tp_print) }; +#if PY_VERSION_HEX < 0x03000000 + offsetof(PyTypeObject, tp_compare), +#endif + offsetof(PyTypeObject, tp_richcompare), + offsetof(PyTypeObject, tp_hash), + offsetof(PyTypeObject, tp_iter), + offsetof(PyTypeObject, tp_repr), + offsetof(PyTypeObject, tp_str), + offsetof(PyTypeObject, tp_print) }; int i; /* Happens when registering gobject.GObject itself, at least. */ @@ -1021,12 +1038,29 @@ pygobject_dealloc(PyGObject *self) PyObject_GC_Del(self); } -static int -pygobject_compare(PyGObject *self, PyGObject *v) +static PyObject* +pygobject_richcompare(PyObject *self, PyObject *other, int op) { - if (self->obj == v->obj) return 0; - if (self->obj > v->obj) return -1; - return 1; + int isinst; + + isinst = PyObject_IsInstance(self, (PyObject*)&PyGObject_Type); + if (isinst == -1) + return NULL; + if (!isinst) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + isinst = PyObject_IsInstance(other, (PyObject*)&PyGObject_Type); + if (isinst == -1) + return NULL; + if (!isinst) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + + return _pyglib_generic_ptr_richcompare(((PyGObject*)self)->obj, + ((PyGObject*)other)->obj, + op); } static long @@ -1046,7 +1080,7 @@ pygobject_repr(PyGObject *self) (long)self, self->obj ? G_OBJECT_TYPE_NAME(self->obj) : "uninitialized", (long)self->obj); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } @@ -1141,7 +1175,7 @@ pygobject_init(PyGObject *self, PyObject *args, PyObject *kwargs) params = g_new0(GParameter, PyDict_Size(kwargs)); while (PyDict_Next (kwargs, &pos, &key, &value)) { GParamSpec *pspec; - gchar *key_str = _PyUnicode_AsString(key); + gchar *key_str = PYGLIB_PyUnicode_AsString(key); pspec = g_object_class_find_property (class, key_str); if (!pspec) { @@ -1249,13 +1283,13 @@ pygobject_get_properties(PyGObject *self, PyObject *args) GValue value = { 0 }; PyObject *item; - if (!_PyUnicode_Check(py_property)) { + if (!PYGLIB_PyUnicode_Check(py_property)) { PyErr_SetString(PyExc_TypeError, "Expected string argument for property."); return NULL; } - property_name = _PyUnicode_AsString(py_property); + property_name = PYGLIB_PyUnicode_AsString(py_property); pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(self->obj), property_name); @@ -1331,7 +1365,7 @@ pygobject_set_properties(PyGObject *self, PyObject *args, PyObject *kwargs) pos = 0; while (kwargs && PyDict_Next (kwargs, &pos, &key, &value)) { - gchar *key_str = _PyUnicode_AsString(key); + gchar *key_str = PYGLIB_PyUnicode_AsString(key); GParamSpec *pspec; pspec = g_object_class_find_property(class, key_str); @@ -1468,7 +1502,7 @@ pygobject_connect(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1517,7 +1551,7 @@ pygobject_connect_after(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1566,7 +1600,7 @@ pygobject_connect_object(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1615,7 +1649,7 @@ pygobject_connect_object_after(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &sigid, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1714,7 +1748,7 @@ pygobject_emit(PyGObject *self, PyObject *args) if (!g_signal_parse_name(name, G_OBJECT_TYPE(self->obj), &signal_id, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), name); return NULL; } @@ -1790,7 +1824,7 @@ pygobject_stop_emission(PyGObject *self, PyObject *args) if (!g_signal_parse_name(signal, G_OBJECT_TYPE(self->obj), &signal_id, &detail, TRUE)) { PyErr_Format(PyExc_TypeError, "%s: unknown signal name: %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)self)), + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)self)), signal); return NULL; } @@ -1938,7 +1972,7 @@ pygobject_disconnect_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyErr_Format(PyExc_TypeError, "nothing connected to %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); return NULL; } @@ -1947,7 +1981,7 @@ pygobject_disconnect_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return _PyLong_FromLong(retval); + return PYGLIB_PyLong_FromLong(retval); } static PyObject * @@ -1970,7 +2004,7 @@ pygobject_handler_block_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyErr_Format(PyExc_TypeError, "nothing connected to %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); return NULL; } @@ -1979,7 +2013,7 @@ pygobject_handler_block_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return _PyLong_FromLong(retval); + return PYGLIB_PyLong_FromLong(retval); } static PyObject * @@ -2002,7 +2036,7 @@ pygobject_handler_unblock_by_func(PyGObject *self, PyObject *args) closure = gclosure_from_pyfunc(self, pyfunc); if (!closure) { PyErr_Format(PyExc_TypeError, "nothing connected to %s", - _PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); + PYGLIB_PyUnicode_AsString(PyObject_Repr((PyObject*)pyfunc))); return NULL; } @@ -2011,7 +2045,7 @@ pygobject_handler_unblock_by_func(PyGObject *self, PyObject *args) 0, 0, closure, NULL, NULL); - return _PyLong_FromLong(retval); + return PYGLIB_PyLong_FromLong(retval); } static PyMethodDef pygobject_methods[] = { @@ -2020,7 +2054,7 @@ static PyMethodDef pygobject_methods[] = { { "get_property", (PyCFunction)pygobject_get_property, METH_VARARGS }, { "get_properties", (PyCFunction)pygobject_get_properties, METH_VARARGS }, { "set_property", (PyCFunction)pygobject_set_property, METH_VARARGS }, - { "set_properties", (PyCFunction)pygobject_set_properties, METH_KEYWORDS }, + { "set_properties", (PyCFunction)pygobject_set_properties, METH_VARARGS|METH_KEYWORDS }, { "freeze_notify", (PyCFunction)pygobject_freeze_notify, METH_VARARGS }, { "notify", (PyCFunction)pygobject_notify, METH_VARARGS }, { "thaw_notify", (PyCFunction)pygobject_thaw_notify, METH_VARARGS }, @@ -2066,7 +2100,7 @@ pygobject_get_dict(PyGObject *self, void *closure) static PyObject * pygobject_get_refcount(PyGObject *self, void *closure) { - return _PyLong_FromLong(self->obj->ref_count); + return PYGLIB_PyLong_FromLong(self->obj->ref_count); } static int @@ -2259,7 +2293,7 @@ pygobject_object_register_types(PyObject *d) pyobject_copy, pyobject_free); PyGObject_Type.tp_dealloc = (destructor)pygobject_dealloc; - PyGObject_Type.tp_compare = (cmpfunc)pygobject_compare; + PyGObject_Type.tp_richcompare = pygobject_richcompare; PyGObject_Type.tp_repr = (reprfunc)pygobject_repr; PyGObject_Type.tp_hash = (hashfunc)pygobject_hash; PyGObject_Type.tp_setattro = (setattrofunc)pygobject_setattro; @@ -2302,7 +2336,7 @@ pygobject_object_register_types(PyObject *d) descr = PyObject_New(PyObject, &PyGPropsDescr_Type); PyDict_SetItemString(PyGObject_Type.tp_dict, "props", descr); PyDict_SetItemString(PyGObject_Type.tp_dict, "__module__", - o=_PyUnicode_FromString("gobject._gobject")); + o=PYGLIB_PyUnicode_FromString("gobject._gobject")); Py_DECREF(o); /* GPropsIter */ diff --git a/gobject/pygobject.h b/gobject/pygobject.h index 85d8bca..e75c890 100644 --- a/gobject/pygobject.h +++ b/gobject/pygobject.h @@ -317,9 +317,32 @@ pygobject_init(int req_major, int req_minor, int req_micro) Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(traceback); + + +#if PY_VERSION_HEX < 0x03000000 PyErr_Format(PyExc_ImportError, "could not import gobject (error was: %s)", PyString_AsString(py_orig_exc)); +#else + { + /* Can not use PyErr_Format because it doesn't have + * a format string for dealing with PyUnicode objects + * like PyUnicode_FromFormat has + */ + PyObject *errmsg = PyUnicode_FromFormat("could not import gobject (error was: %U)", + py_orig_exc); + + if (errmsg) { + PyErr_SetObject(PyExc_ImportError, + errmsg); + Py_DECREF(errmsg); + } + /* if errmsg is NULL then we might have OOM + * PyErr should already be set and trying to + * return our own error would be futile + */ + } +#endif Py_DECREF(py_orig_exc); } else { PyErr_SetString(PyExc_ImportError, diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c index be3840b..7743629 100644 --- a/gobject/pygparamspec.c +++ b/gobject/pygparamspec.c @@ -32,12 +32,17 @@ PYGLIB_DEFINE_TYPE("gobject.GParamSpec", PyGParamSpec_Type, PyGParamSpec); -static int -pyg_param_spec_compare(PyGParamSpec *self, PyGParamSpec *v) +static PyObject* +pyg_param_spec_richcompare(PyObject *self, PyObject *other, int op) { - if (self->pspec == v->pspec) return 0; - if (self->pspec > v->pspec) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGParamSpec_Type) + return _pyglib_generic_ptr_richcompare(((PyGParamSpec*)self)->pspec, + ((PyGParamSpec*)other)->pspec, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static long @@ -54,7 +59,7 @@ pyg_param_spec_repr(PyGParamSpec *self) g_snprintf(buf, sizeof(buf), "<%s '%s'>", G_PARAM_SPEC_TYPE_NAME(self->pspec), g_param_spec_get_name(self->pspec)); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static void @@ -121,7 +126,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) } else if (!strcmp(attr, "blurb") || !strcmp(attr, "__doc__")) { return Py_BuildValue("s", g_param_spec_get_blurb(pspec)); } else if (!strcmp(attr, "flags")) { - return _PyLong_FromLong(pspec->flags); + return PYGLIB_PyLong_FromLong(pspec->flags); } else if (!strcmp(attr, "value_type")) { return pyg_type_wrapper_new(pspec->value_type); } else if (!strcmp(attr, "owner_type")) { @@ -135,12 +140,12 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "maximum", "minimum", "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_CHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return _PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return _PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->maximum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UCHAR(pspec)) { if (!strcmp(attr, "__members__")) { @@ -150,12 +155,12 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_UCHAR(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return _PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return _PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->maximum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_BOOLEAN(pspec)) { if (!strcmp(attr, "__members__")) { @@ -173,11 +178,11 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "flags", "maximum", "minimum", "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->default_value); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->default_value); } else if (!strcmp(attr, "minimum")) { - return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->minimum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->minimum); } else if (!strcmp(attr, "maximum")) { - return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->maximum); + return PYGLIB_PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->maximum); } } else if (G_IS_PARAM_SPEC_UINT(pspec)) { if (!strcmp(attr, "__members__")) { @@ -253,7 +258,7 @@ pyg_param_spec_getattr(PyGParamSpec *self, const gchar *attr) "flags", "name", "nick", "owner_type", "value_type"); } else if (!strcmp(attr, "default_value")) { - return _PyUnicode_FromFormat( + return PYGLIB_PyUnicode_FromFormat( "%c", G_PARAM_SPEC_UNICHAR(pspec)->default_value); } } else if (G_IS_PARAM_SPEC_ENUM(pspec)) { @@ -387,10 +392,12 @@ pygobject_paramspec_register_types(PyObject *d) Py_TYPE(&PyGParamSpec_Type) = &PyType_Type; PyGParamSpec_Type.tp_dealloc = (destructor)pyg_param_spec_dealloc; PyGParamSpec_Type.tp_getattr = (getattrfunc)pyg_param_spec_getattr; - PyGParamSpec_Type.tp_compare = (cmpfunc)pyg_param_spec_compare; + PyGParamSpec_Type.tp_richcompare = pyg_param_spec_richcompare; + PyGParamSpec_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGParamSpec_Type.tp_repr = (reprfunc)pyg_param_spec_repr; PyGParamSpec_Type.tp_hash = (hashfunc)pyg_param_spec_hash; + if (PyType_Ready(&PyGParamSpec_Type)) return; PyDict_SetItemString(d, "GParamSpec", (PyObject *)&PyGParamSpec_Type); diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c index 95bfae9..fbe3e10 100644 --- a/gobject/pygpointer.c +++ b/gobject/pygpointer.c @@ -41,12 +41,17 @@ pyg_pointer_dealloc(PyGPointer *self) Py_TYPE(self)->tp_free((PyObject *)self); } -static int -pyg_pointer_compare(PyGPointer *self, PyGPointer *v) +static PyObject* +pyg_pointer_richcompare(PyObject *self, PyObject *other, int op) { - if (self->pointer == v->pointer) return 0; - if (self->pointer > v->pointer) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGPointer_Type) + return _pyglib_generic_ptr_richcompare(((PyGPointer*)self)->pointer, + ((PyGPointer*)other)->pointer, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static long @@ -62,7 +67,7 @@ pyg_pointer_repr(PyGPointer *self) g_snprintf(buf, sizeof(buf), "<%s at 0x%lx>", g_type_name(self->gtype), (long)self->pointer); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static int @@ -183,7 +188,7 @@ pygobject_pointer_register_types(PyObject *d) pygpointer_class_key = g_quark_from_static_string("PyGPointer::class"); PyGPointer_Type.tp_dealloc = (destructor)pyg_pointer_dealloc; - PyGPointer_Type.tp_compare = (cmpfunc)pyg_pointer_compare; + PyGPointer_Type.tp_richcompare = pyg_pointer_richcompare; PyGPointer_Type.tp_repr = (reprfunc)pyg_pointer_repr; PyGPointer_Type.tp_hash = (hashfunc)pyg_pointer_hash; PyGPointer_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; diff --git a/gobject/pygtype.c b/gobject/pygtype.c index 5550ce8..c875aa2 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -39,12 +39,17 @@ typedef struct { PYGLIB_DEFINE_TYPE("gobject.GType", PyGTypeWrapper_Type, PyGTypeWrapper); -static int -pyg_type_wrapper_compare(PyGTypeWrapper *self, PyGTypeWrapper *v) +static PyObject* +pyg_type_wrapper_richcompare(PyObject *self, PyObject *other, int op) { - if (self->type == v->type) return 0; - if (self->type > v->type) return -1; - return 1; + if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGTypeWrapper_Type) + return _pyglib_generic_long_richcompare(((PyGTypeWrapper*)self)->type, + ((PyGTypeWrapper*)other)->type, + op); + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } } static long @@ -61,7 +66,7 @@ pyg_type_wrapper_repr(PyGTypeWrapper *self) g_snprintf(buf, sizeof(buf), "", name?name:"invalid", (unsigned long int) self->type); - return _PyUnicode_FromString(buf); + return PYGLIB_PyUnicode_FromString(buf); } static void @@ -134,7 +139,7 @@ static PyObject * _wrap_g_type_wrapper__get_name(PyGTypeWrapper *self, void *closure) { const char *name = g_type_name(self->type); - return _PyUnicode_FromString(name ? name : "invalid"); + return PYGLIB_PyUnicode_FromString(name ? name : "invalid"); } static PyObject * @@ -155,14 +160,14 @@ _wrap_g_type_wrapper__get_children(PyGTypeWrapper *self, void *closure) guint n_children, i; GType *children; PyObject *retval; - + children = g_type_children(self->type, &n_children); retval = PyList_New(n_children); for (i = 0; i < n_children; i++) PyList_SetItem(retval, i, pyg_type_wrapper_new(children[i])); g_free(children); - + return retval; } @@ -172,21 +177,21 @@ _wrap_g_type_wrapper__get_interfaces(PyGTypeWrapper *self, void *closure) guint n_interfaces, i; GType *interfaces; PyObject *retval; - + interfaces = g_type_interfaces(self->type, &n_interfaces); retval = PyList_New(n_interfaces); for (i = 0; i < n_interfaces; i++) PyList_SetItem(retval, i, pyg_type_wrapper_new(interfaces[i])); g_free(interfaces); - + return retval; } static PyObject * _wrap_g_type_wrapper__get_depth(PyGTypeWrapper *self, void *closure) { - return _PyLong_FromLong(g_type_depth(self->type)); + return PYGLIB_PyLong_FromLong(g_type_depth(self->type)); } static PyGetSetDef _PyGTypeWrapper_getsets[] = { @@ -259,7 +264,7 @@ _wrap_g_type_from_name(PyGTypeWrapper *_, PyObject *args) { char *type_name; GType type; - + if (!PyArg_ParseTuple(args, "s:GType.from_name", &type_name)) return NULL; @@ -282,7 +287,7 @@ _wrap_g_type_is_a(PyGTypeWrapper *self, PyObject *args) return NULL; else if ((parent = pyg_type_from_object(gparent)) == 0) return NULL; - + return PyBool_FromLong(g_type_is_a(self->type, parent)); } @@ -300,14 +305,14 @@ static PyMethodDef _PyGTypeWrapper_methods[] = { { "is_a", (PyCFunction)_wrap_g_type_is_a, METH_VARARGS }, { NULL, 0, 0 } }; - + static int pyg_type_wrapper_init(PyGTypeWrapper *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "object", NULL }; PyObject *py_object; GType type; - + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GType.__init__", kwlist, &py_object)) @@ -370,7 +375,7 @@ pyg_type_from_object(PyObject *obj) if (PyType_Check(obj)) { PyTypeObject *tp = (PyTypeObject *)obj; - if (tp == &_PyLong_Type) + if (tp == &PYGLIB_PyLong_Type) return G_TYPE_INT; else if (tp == &PyBool_Type) return G_TYPE_BOOLEAN; @@ -378,7 +383,7 @@ pyg_type_from_object(PyObject *obj) return G_TYPE_LONG; else if (tp == &PyFloat_Type) return G_TYPE_DOUBLE; - else if (tp == &_PyUnicode_Type) + else if (tp == &PYGLIB_PyUnicode_Type) return G_TYPE_STRING; else if (tp == &PyBaseObject_Type) return PY_TYPE_OBJECT; @@ -389,9 +394,9 @@ pyg_type_from_object(PyObject *obj) } /* handle strings */ - if (_PyUnicode_Check(obj)) { - gchar *name = _PyUnicode_AsString(obj); - + if (PYGLIB_PyUnicode_Check(obj)) { + gchar *name = PYGLIB_PyUnicode_AsString(obj); + type = _pyg_type_from_name(name); if (type != 0) { return type; @@ -440,8 +445,8 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val) if (!obj) { *val = 0; res = 0; - } else if (_PyLong_Check(obj)) { - *val = _PyLong_AsLong(obj); + } else if (PYGLIB_PyLong_Check(obj)) { + *val = PYGLIB_PyLong_AsLong(obj); res = 0; if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) { @@ -459,10 +464,10 @@ pyg_enum_get_value(GType enum_type, PyObject *obj, gint *val) g_type_name(enum_type), g_type_name(((PyGEnum *) obj)->gtype)); } - } else if (_PyUnicode_Check(obj)) { + } else if (PYGLIB_PyUnicode_Check(obj)) { GEnumValue *info; - char *str = _PyUnicode_AsString(obj); - + char *str = PYGLIB_PyUnicode_AsString(obj); + if (enum_type != G_TYPE_NONE) eclass = G_ENUM_CLASS(g_type_class_ref(enum_type)); else { @@ -513,15 +518,15 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, gint *val) if (!obj) { *val = 0; res = 0; - } else if (_PyLong_Check(obj)) { - *val = _PyLong_AsLong(obj); + } else if (PYGLIB_PyLong_Check(obj)) { + *val = PYGLIB_PyLong_AsLong(obj); res = 0; } else if (PyLong_Check(obj)) { *val = PyLong_AsLongLong(obj); res = 0; - } else if (_PyUnicode_Check(obj)) { + } else if (PYGLIB_PyUnicode_Check(obj)) { GFlagsValue *info; - char *str = _PyUnicode_AsString(obj); + char *str = PYGLIB_PyUnicode_AsString(obj); if (flag_type != G_TYPE_NONE) fclass = G_FLAGS_CLASS(g_type_class_ref(flag_type)); @@ -531,7 +536,7 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, gint *val) } info = g_flags_get_value_by_name(fclass, str); g_type_class_unref(fclass); - + if (!info) info = g_flags_get_value_by_nick(fclass, str); if (info) { @@ -557,7 +562,7 @@ pyg_flags_get_value(GType flag_type, PyObject *obj, gint *val) for (i = 0; i < len; i++) { PyObject *item = PyTuple_GetItem(obj, i); - char *str = _PyUnicode_AsString(item); + char *str = PYGLIB_PyUnicode_AsString(item); GFlagsValue *info = g_flags_get_value_by_name(fclass, str); if (!info) @@ -644,7 +649,7 @@ pyg_value_array_from_pyobject(GValue *value, if (pspec && pspec->fixed_n_elements > 0 && len != pspec->fixed_n_elements) return -1; - + value_array = g_value_array_new(len); for (i = 0; i < len; ++i) { @@ -732,7 +737,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) break; case G_TYPE_CHAR: if ((tmp = PyObject_Str(obj))) - g_value_set_char(value, _PyUnicode_AsString(tmp)[0]); + g_value_set_char(value, PYGLIB_PyUnicode_AsString(tmp)[0]); else { PyErr_Clear(); return -1; @@ -740,15 +745,15 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) Py_DECREF(tmp); break; case G_TYPE_UCHAR: - if (_PyLong_Check(obj)) { - glong val; - val = _PyLong_AsLong(obj); + if (PYGLIB_PyLong_Check(obj)) { + glong val; + val = PYGLIB_PyLong_AsLong(obj); if (val >= 0 && val <= 255) - g_value_set_uchar(value, (guchar)_PyLong_AsLong (obj)); + g_value_set_uchar(value, (guchar)PYGLIB_PyLong_AsLong (obj)); else return -1; } else if ((tmp = PyObject_Str(obj))) { - g_value_set_uchar(value, _PyUnicode_AsString(tmp)[0]); + g_value_set_uchar(value, PYGLIB_PyUnicode_AsString(tmp)[0]); Py_DECREF(tmp); } else { PyErr_Clear(); @@ -759,14 +764,14 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) g_value_set_boolean(value, PyObject_IsTrue(obj)); break; case G_TYPE_INT: - g_value_set_int(value, _PyLong_AsLong(obj)); + g_value_set_int(value, PYGLIB_PyLong_AsLong(obj)); break; case G_TYPE_UINT: { - if (_PyLong_Check(obj)) { + if (PYGLIB_PyLong_Check(obj)) { glong val; - val = _PyLong_AsLong(obj); + val = PYGLIB_PyLong_AsLong(obj); if (val >= 0 && val <= G_MAXUINT) g_value_set_uint(value, (guint)val); else @@ -777,23 +782,26 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) } break; case G_TYPE_LONG: - g_value_set_long(value, _PyLong_AsLong(obj)); + g_value_set_long(value, PYGLIB_PyLong_AsLong(obj)); break; case G_TYPE_ULONG: - { - if (_PyLong_Check(obj)) { - glong val; +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long val; - val = _PyLong_AsLong(obj); - if (val >= 0) - g_value_set_ulong(value, (gulong)val); - else - return -1; - } else { - g_value_set_ulong(value, PyLong_AsUnsignedLong(obj)); - } - } - break; + val = PYGLIB_PyLong_AsLong(obj); + if (val < 0) { + PyErr_SetString(PyExc_OverflowError, "negative value not allowed for uint64 property"); + return -1; + } + g_value_set_ulong(value, (gulong)val); + } else +#endif + if (PyLong_Check(obj)) + g_value_set_ulong(value, PyLong_AsUnsignedLong(obj)); + else + return -1; + break; case G_TYPE_INT64: g_value_set_int64(value, PyLong_AsLongLong(obj)); break; @@ -843,7 +851,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) if (obj == Py_None) g_value_set_string(value, NULL); else if ((tmp = PyObject_Str(obj))) { - g_value_set_string(value, _PyUnicode_AsString(tmp)); + g_value_set_string(value, PYGLIB_PyUnicode_AsString(tmp)); Py_DECREF(tmp); } else { PyErr_Clear(); @@ -873,8 +881,8 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) g_value_set_boxed(value, pyg_boxed_get(obj, gpointer)); else if (G_VALUE_HOLDS(value, G_TYPE_VALUE)) { GType type; - GValue *n_value; - + GValue *n_value; + type = pyg_type_from_object((PyObject*)Py_TYPE(obj)); if (G_UNLIKELY (! type)) { PyErr_Clear(); @@ -888,12 +896,12 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj) else if (PySequence_Check(obj) && G_VALUE_HOLDS(value, G_TYPE_VALUE_ARRAY)) return pyg_value_array_from_pyobject(value, obj, NULL); - else if (_PyUnicode_Check(obj) && + else if (PYGLIB_PyUnicode_Check(obj) && G_VALUE_HOLDS(value, G_TYPE_GSTRING)) { GString *string; char *buffer; Py_ssize_t len; - if (_PyUnicode_AsStringAndSize(obj, &buffer, &len)) + if (PYGLIB_PyUnicode_AsStringAndSize(obj, &buffer, &len)) return -1; string = g_string_new_len(buffer, len); g_value_set_boxed(value, string); @@ -963,17 +971,17 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) break; case G_TYPE_CHAR: { gint8 val = g_value_get_char(value); - return _PyUnicode_FromStringAndSize((char *)&val, 1); + return PYGLIB_PyUnicode_FromStringAndSize((char *)&val, 1); } case G_TYPE_UCHAR: { guint8 val = g_value_get_uchar(value); - return _PyUnicode_FromStringAndSize((char *)&val, 1); + return PYGLIB_PyUnicode_FromStringAndSize((char *)&val, 1); } case G_TYPE_BOOLEAN: { return PyBool_FromLong(g_value_get_boolean(value)); } case G_TYPE_INT: - return _PyLong_FromLong(g_value_get_int(value)); + return PYGLIB_PyLong_FromLong(g_value_get_int(value)); case G_TYPE_UINT: { /* in Python, the Int object is backed by a long. If a @@ -981,19 +989,19 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) an Int. Otherwise, use a Long object to avoid overflow. This matches the ULongArg behavior in codegen/argtypes.h */ #if (G_MAXUINT <= G_MAXLONG) - return _PyLong_FromLong((glong) g_value_get_uint(value)); + return PYGLIB_PyLong_FromLong((glong) g_value_get_uint(value)); #else return PyLong_FromUnsignedLong((gulong) g_value_get_uint(value)); #endif } case G_TYPE_LONG: - return _PyLong_FromLong(g_value_get_long(value)); + return PYGLIB_PyLong_FromLong(g_value_get_long(value)); case G_TYPE_ULONG: { gulong val = g_value_get_ulong(value); if (val <= G_MAXLONG) - return _PyLong_FromLong((glong) val); + return PYGLIB_PyLong_FromLong((glong) val); else return PyLong_FromUnsignedLong(val); } @@ -1002,7 +1010,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) gint64 val = g_value_get_int64(value); if (G_MINLONG <= val && val <= G_MAXLONG) - return _PyLong_FromLong((glong) val); + return PYGLIB_PyLong_FromLong((glong) val); else return PyLong_FromLongLong(val); } @@ -1011,7 +1019,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) guint64 val = g_value_get_uint64(value); if (val <= G_MAXLONG) - return _PyLong_FromLong((glong) val); + return PYGLIB_PyLong_FromLong((glong) val); else return PyLong_FromUnsignedLongLong(val); } @@ -1028,7 +1036,7 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) const gchar *str = g_value_get_string(value); if (str) - return _PyUnicode_FromString(str); + return PYGLIB_PyUnicode_FromString(str); Py_INCREF(Py_None); return Py_None; } @@ -1058,9 +1066,9 @@ pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed) return ret; } else if (G_VALUE_HOLDS(value, G_TYPE_GSTRING)) { GString *string = (GString *) g_value_get_boxed(value); - PyObject *ret = _PyUnicode_FromStringAndSize(string->str, string->len); + PyObject *ret = PYGLIB_PyUnicode_FromStringAndSize(string->str, string->len); return ret; - } + } bm = pyg_type_lookup(G_VALUE_TYPE(value)); if (bm) { return bm->fromvalue(value); @@ -1157,18 +1165,18 @@ pyg_closure_marshal(GClosure *closure, PyErr_Print(); goto out; } - + if (return_value && pyg_value_from_pyobject(return_value, ret) != 0) { PyErr_SetString(PyExc_TypeError, "can't convert return value to desired type"); - + if (pc->exception_handler) pc->exception_handler(return_value, n_param_values, param_values); else PyErr_Print(); } Py_DECREF(ret); - + out: Py_DECREF(params); pyglib_gil_state_release(state); @@ -1220,7 +1228,7 @@ pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data) * @handler: the handler to call when an exception occurs or NULL for none * * Sets the handler to call when an exception occurs during closure invocation. - * The handler is responsible for providing a proper return value to the + * The handler is responsible for providing a proper return value to the * closure invocation. If @handler is %NULL, the default handler will be used. * The default handler prints the exception to stderr and doesn't touch the * closure's return value. @@ -1230,7 +1238,7 @@ pyg_closure_set_exception_handler(GClosure *closure, PyClosureExceptionHandler handler) { PyGClosure *pygclosure; - + g_return_if_fail(closure != NULL); pygclosure = (PyGClosure *)closure; @@ -1265,7 +1273,7 @@ pyg_signal_class_closure_marshal(GClosure *closure, guint i, len; state = pyglib_gil_state_ensure(); - + g_return_if_fail(invocation_hint != NULL); /* get the object passed as the first argument to the closure */ object = g_value_get_object(¶m_values[0]); @@ -1311,10 +1319,10 @@ pyg_signal_class_closure_marshal(GClosure *closure, } ret = PyObject_CallObject(method, params); - + /* Copy boxed values if others ref them, this needs to be done regardless of exception status. */ - len = PyTuple_Size(params); + len = PyTuple_Size(params); for (i = 0; i < len; i++) { PyObject *item = PyTuple_GetItem(params, i); if (item != NULL && PyObject_TypeCheck(item, &PyGBoxed_Type) @@ -1372,13 +1380,13 @@ gclosure_from_pyfunc(PyGObject *object, PyObject *func) GSList *l; PyGObjectData *inst_data; inst_data = pyg_object_peek_inst_data(object->obj); - if (inst_data) - { + if (inst_data) { for (l = inst_data->closures; l; l = l->next) { PyGClosure *pyclosure = l->data; - int res; - PyObject_Cmp(pyclosure->callback, func, &res); - if (!res) { + int res = PyObject_RichCompareBool(pyclosure->callback, func, Py_EQ); + if (res == -1) { + PyErr_Clear(); // Is there anything else to do? + } else if (res) { return (GClosure*)pyclosure; } } @@ -1464,7 +1472,7 @@ add_property_docs(GType gtype, GString *string) g_type_name(props[i]->value_type), g_param_spec_get_nick(props[i])); - /* g_string_append_printf crashes on win32 if the third + /* g_string_append_printf crashes on win32 if the third argument is NULL. */ blurb=g_param_spec_get_blurb(props[i]); if (blurb) @@ -1514,7 +1522,7 @@ object_doc_descr_get(PyObject *self, PyObject *obj, PyObject *type) g_array_append_val(parents, parent); parent = g_type_next_base(gtype, parent); } - + for (iparent = parents->len - 1; iparent >= 0; --iparent) { GType *interfaces; guint n_interfaces, i; @@ -1532,7 +1540,7 @@ object_doc_descr_get(PyObject *self, PyObject *obj, PyObject *type) g_array_free(parents, TRUE); } - pystring = _PyUnicode_FromStringAndSize(string->str, string->len); + pystring = PYGLIB_PyUnicode_FromStringAndSize(string->str, string->len); g_string_free(string, TRUE); return pystring; } @@ -1582,7 +1590,7 @@ int pyg_pyobj_to_unichar_conv(PyObject* py_obj, void* ptr) gunichar* u = ptr; const Py_UNICODE* uni_buffer; PyObject* tmp_uni = NULL; - + if (PyUnicode_Check(py_obj)) { tmp_uni = py_obj; Py_INCREF(tmp_uni); @@ -1592,7 +1600,7 @@ int pyg_pyobj_to_unichar_conv(PyObject* py_obj, void* ptr) if (tmp_uni == NULL) goto failure; } - + if ( PyUnicode_GetSize(tmp_uni) != 1) { PyErr_SetString(PyExc_ValueError, "unicode character value must be 1 character uniode string"); goto failure; @@ -1601,24 +1609,24 @@ int pyg_pyobj_to_unichar_conv(PyObject* py_obj, void* ptr) if ( uni_buffer == NULL) goto failure; *u = uni_buffer[0]; - + Py_DECREF(tmp_uni); return 1; - + failure: Py_XDECREF(tmp_uni); return 0; } -int -pyg_param_gvalue_from_pyobject(GValue* value, - PyObject* py_obj, +int +pyg_param_gvalue_from_pyobject(GValue* value, + PyObject* py_obj, const GParamSpec* pspec) { if (G_IS_PARAM_SPEC_UNICHAR(pspec)) { gunichar u; - + if (!pyg_pyobj_to_unichar_conv(py_obj, &u)) { PyErr_Clear(); return -1; @@ -1634,15 +1642,15 @@ pyg_param_gvalue_from_pyobject(GValue* value, } } -PyObject* +PyObject* pyg_param_gvalue_as_pyobject(const GValue* gvalue, - gboolean copy_boxed, + gboolean copy_boxed, const GParamSpec* pspec) { if (G_IS_PARAM_SPEC_UNICHAR(pspec)) { gunichar u; Py_UNICODE uni_buffer[2] = { 0, 0 }; - + u = g_value_get_uint(gvalue); uni_buffer[0] = u; return PyUnicode_FromUnicode(uni_buffer, 1); @@ -1663,7 +1671,7 @@ typedef struct { gpointer data; } CustomTypeData; -void +void pyg_type_register_custom_callback(const gchar *typename, PyGTypeRegistrationFunction callback, gpointer user_data) @@ -1688,7 +1696,7 @@ pyg_type_get_custom(const gchar *name) { CustomTypeData *data; PyTypeObject *retval; - + if (!custom_type_registration) return NULL; @@ -1713,7 +1721,7 @@ _pyg_type_from_name(const gchar *name) pyg_type_get_custom(name); type = g_type_from_name(name); } - + return type; } @@ -1730,7 +1738,7 @@ _pyg_strv_from_gvalue(const GValue *value) } py_argv = PyList_New(argc); for (i = 0; i < argc; ++i) - PyList_SET_ITEM(py_argv, i, _PyUnicode_FromString(argv[i])); + PyList_SET_ITEM(py_argv, i, PYGLIB_PyUnicode_FromString(argv[i])); return py_argv; } @@ -1745,11 +1753,11 @@ _pyg_strv_to_gvalue(GValue *value, PyObject *obj) argc = PySequence_Length(obj); for (i = 0; i < argc; ++i) - if (!_PyUnicode_Check(PySequence_Fast_GET_ITEM(obj, i))) + if (!PYGLIB_PyUnicode_Check(PySequence_Fast_GET_ITEM(obj, i))) return -1; argv = g_new(gchar *, argc + 1); for (i = 0; i < argc; ++i) - argv[i] = g_strdup(_PyUnicode_AsString(PySequence_Fast_GET_ITEM(obj, i))); + argv[i] = g_strdup(PYGLIB_PyUnicode_AsString(PySequence_Fast_GET_ITEM(obj, i))); argv[i] = NULL; g_value_take_boxed(value, argv); return 0; @@ -1759,7 +1767,7 @@ void pygobject_type_register_types(PyObject *d) { PyGTypeWrapper_Type.tp_dealloc = (destructor)pyg_type_wrapper_dealloc; - PyGTypeWrapper_Type.tp_compare = (cmpfunc)pyg_type_wrapper_compare; + PyGTypeWrapper_Type.tp_richcompare = pyg_type_wrapper_richcompare; PyGTypeWrapper_Type.tp_repr = (reprfunc)pyg_type_wrapper_repr; PyGTypeWrapper_Type.tp_hash = (hashfunc)pyg_type_wrapper_hash; PyGTypeWrapper_Type.tp_flags = Py_TPFLAGS_DEFAULT; @@ -1772,7 +1780,7 @@ pygobject_type_register_types(PyObject *d) PyGObjectDoc_Type.tp_dealloc = (destructor)object_doc_dealloc; PyGObjectDoc_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGObjectDoc_Type.tp_descr_get = (descrgetfunc)object_doc_descr_get; - + pyg_register_gtype_custom(G_TYPE_STRV, _pyg_strv_from_gvalue, _pyg_strv_to_gvalue); diff --git a/tests/Makefile.am b/tests/Makefile.am index d0b1ca1..77bc020 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,20 +1,51 @@ -INCLUDES = \ - -I$(top_srcdir)/gobject \ - $(PYTHON_INCLUDES) \ - $(GLIB_CFLAGS) +CLEANFILES = +noinst_LTLIBRARIES = +if ENABLE_INTROSPECTION +noinst_LTLIBRARIES += libregress.la libgimarshallingtests.la -EXTRA_DIST = \ - $(tests) \ - common.py \ - runtests.py \ - testmodule.py \ - test-floating.h \ - test-thread.h \ - test-unknown.h +nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h +libregress_la_CFLAGS = $(GIO_CFLAGS) $(PYCAIRO_CFLAGS) +libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(PYCAIRO_LIBS) +nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h +libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS) +libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) + +# This is a hack to make sure a shared library is built +libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES) + $(LINK) -rpath $(pkgpyexecdir) $(libregress_la_LDFLAGS) $(libregress_la_OBJECTS) $(libregress_la_LIBADD) $(LIBS) + +libgimarshallingtests.la: $(libgimarshallingtests_la_OBJECTS) $(libgimarshallingtests_la_DEPENDENCIES) + $(LINK) -rpath $(pkgpyexecdir) $(libgimarshallingtests_la_LDFLAGS) $(libgimarshallingtests_la_OBJECTS) $(libgimarhallingtests_la_LIBADD) $(LIBS) + +# g-i doesn't ship these as shared libraries anymore; we build them here +Regress-1.0.gir: libregress.la Makefile + $(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \ + --namespace=Regress --nsversion=1.0 \ + --warn-all --warn-error \ + --library=libregress.la \ + --libtool="$(top_builddir)/libtool" \ + --output $@ \ + $(nodist_libregress_la_SOURCES) +Regress-1.0.typelib: Regress-1.0.gir Makefile + $(AM_V_GEN) g-ir-compiler $< -o $@ + +GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile + $(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \ + --namespace=GIMarshallingTests --nsversion=1.0 --symbol-prefix=gi_marshalling_tests \ + --warn-all --warn-error \ + --library=libgimarshallingtests.la \ + --libtool="$(top_builddir)/libtool" \ + --output $@ \ + $(nodist_libgimarshallingtests_la_SOURCES) +GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile + $(AM_V_GEN) g-ir-compiler $< -o $@ -noinst_LTLIBRARIES = testhelper.la -linked_LIBS = testhelper.la +CLEANFILES += Regress-1.0.gir Regress-1.0.typelib GIMarshallingTests-1.0.gir GIMarshallingTests-1.0.typelib +endif + +noinst_LTLIBRARIES += testhelper.la +testhelper_la_CFLAGS = -I$(top_srcdir)/gobject -I$(top_srcdir)/glib $(PYTHON_INCLUDES) $(GLIB_CFLAGS) testhelper_la_LDFLAGS = -module -avoid-version testhelper_la_LIBADD = $(GLIB_LIBS) testhelper_la_SOURCES = \ @@ -23,49 +54,64 @@ testhelper_la_SOURCES = \ test-thread.c \ test-unknown.c -tests = \ - test_gicon.py \ - test_gio.py \ +# This is a hack to make sure a shared library is built +testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES) + $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS) + + +.la.so: + test -L $@ || $(LN_S) .libs/$@ $@ + + +all: $(LTLIBRARIES:.la=.so) + +TEST_FILES = \ test_gobject.py \ test_interface.py \ test_mainloop.py \ + test_option.py \ test_properties.py \ test_signal.py \ + test_source.py \ test_subprocess.py \ - test_unknown.py \ - test_source.py + test_thread.py \ + test_uris.py + +if BUILD_GIO +TEST_FILES += \ + test_gio.py \ + test_gresolver.py \ + test_gsocket.py \ + test_gicon.py \ + test_gcancellable.py +endif if ENABLE_INTROSPECTION -tests += \ +TEST_FILES += \ test_everything.py \ test_gi.py \ test_overrides.py endif -# This is a hack to make sure a shared library is built -testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES) - $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS) - -check-local: $(LTLIBRARIES:.la=.so) - $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py $(top_builddir) $(tests) +EXTRA_DIST = \ + compathelper.py \ + runtests.py \ + testmodule.py \ + test-floating.h \ + test-thread.h \ + test-unknown.h -all: $(LTLIBRARIES:.la=.so) +EXTRA_DIST += $(TEST_FILES) clean-local: - rm -f $(LTLIBRARIES:.la=.so) + rm -f $(LTLIBRARIES:.la=.so) file.txt~ -.la.so: - $(LN_S) .libs/$@ $@ || true + +check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib + TEST_FILES="$(TEST_FILES)" PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(builddir) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py check.gdb: EXEC_NAME="gdb --args" $(MAKE) check -%.gdb: - EXEC_NAME="gdb --args" TEST_NAMES=$* $(MAKE) check - check.valgrind: - EXEC_NAME="valgrind" $(MAKE) check - -%.valgrind: - EXEC_NAME="valgrind" TEST_NAMES=$* $(MAKE) check - + EXEC_NAME="valgrind" G_SLICE=always-malloc G_DEBUG=gc-friendly $(MAKE) check diff --git a/tests/Makefile.in b/tests/Makefile.in index 5a99d63..e9c6223 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -34,7 +34,16 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@ENABLE_INTROSPECTION_TRUE@am__append_1 = \ +@ENABLE_INTROSPECTION_TRUE@am__append_1 = libregress.la libgimarshallingtests.la +@ENABLE_INTROSPECTION_TRUE@am__append_2 = Regress-1.0.gir Regress-1.0.typelib GIMarshallingTests-1.0.gir GIMarshallingTests-1.0.typelib +@BUILD_GIO_TRUE@am__append_3 = \ +@BUILD_GIO_TRUE@ test_gio.py \ +@BUILD_GIO_TRUE@ test_gresolver.py \ +@BUILD_GIO_TRUE@ test_gsocket.py \ +@BUILD_GIO_TRUE@ test_gicon.py \ +@BUILD_GIO_TRUE@ test_gcancellable.py + +@ENABLE_INTROSPECTION_TRUE@am__append_4 = \ @ENABLE_INTROSPECTION_TRUE@ test_everything.py \ @ENABLE_INTROSPECTION_TRUE@ test_gi.py \ @ENABLE_INTROSPECTION_TRUE@ test_overrides.py @@ -54,17 +63,35 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) -am__DEPENDENCIES_1 = -testhelper_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_testhelper_la_OBJECTS = testhelpermodule.lo test-floating.lo \ - test-thread.lo test-unknown.lo -testhelper_la_OBJECTS = $(am_testhelper_la_OBJECTS) +libgimarshallingtests_la_LIBADD = +@ENABLE_INTROSPECTION_TRUE@nodist_libgimarshallingtests_la_OBJECTS = libgimarshallingtests_la-gimarshallingtests.lo +libgimarshallingtests_la_OBJECTS = \ + $(nodist_libgimarshallingtests_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent +libgimarshallingtests_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libgimarshallingtests_la_CFLAGS) $(CFLAGS) \ + $(libgimarshallingtests_la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_INTROSPECTION_TRUE@am_libgimarshallingtests_la_rpath = +libregress_la_LIBADD = +@ENABLE_INTROSPECTION_TRUE@nodist_libregress_la_OBJECTS = \ +@ENABLE_INTROSPECTION_TRUE@ libregress_la-regress.lo +libregress_la_OBJECTS = $(nodist_libregress_la_OBJECTS) +libregress_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libregress_la_CFLAGS) \ + $(CFLAGS) $(libregress_la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_INTROSPECTION_TRUE@am_libregress_la_rpath = +am__DEPENDENCIES_1 = +testhelper_la_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_testhelper_la_OBJECTS = testhelper_la-testhelpermodule.lo \ + testhelper_la-test-floating.lo testhelper_la-test-thread.lo \ + testhelper_la-test-unknown.lo +testhelper_la_OBJECTS = $(am_testhelper_la_OBJECTS) testhelper_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(testhelper_la_LDFLAGS) $(LDFLAGS) -o $@ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(testhelper_la_CFLAGS) \ + $(CFLAGS) $(testhelper_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -91,7 +118,8 @@ am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(testhelper_la_SOURCES) +SOURCES = $(nodist_libgimarshallingtests_la_SOURCES) \ + $(nodist_libregress_la_SOURCES) $(testhelper_la_SOURCES) DIST_SOURCES = $(testhelper_la_SOURCES) ETAGS = etags CTAGS = ctags @@ -131,6 +159,7 @@ GIOUNIX_LIBS = @GIOUNIX_LIBS@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GI_CFLAGS = @GI_CFLAGS@ +GI_DATADIR = @GI_DATADIR@ GI_LIBS = @GI_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ @@ -250,22 +279,15 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -INCLUDES = \ - -I$(top_srcdir)/gobject \ - $(PYTHON_INCLUDES) \ - $(GLIB_CFLAGS) - -EXTRA_DIST = \ - $(tests) \ - common.py \ - runtests.py \ - testmodule.py \ - test-floating.h \ - test-thread.h \ - test-unknown.h - -noinst_LTLIBRARIES = testhelper.la -linked_LIBS = testhelper.la +CLEANFILES = $(am__append_2) +noinst_LTLIBRARIES = $(am__append_1) testhelper.la +@ENABLE_INTROSPECTION_TRUE@nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h +@ENABLE_INTROSPECTION_TRUE@libregress_la_CFLAGS = $(GIO_CFLAGS) $(PYCAIRO_CFLAGS) +@ENABLE_INTROSPECTION_TRUE@libregress_la_LDFLAGS = -module -avoid-version $(GIO_LIBS) $(PYCAIRO_LIBS) +@ENABLE_INTROSPECTION_TRUE@nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h +@ENABLE_INTROSPECTION_TRUE@libgimarshallingtests_la_CFLAGS = $(GLIB_CFLAGS) +@ENABLE_INTROSPECTION_TRUE@libgimarshallingtests_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) +testhelper_la_CFLAGS = -I$(top_srcdir)/gobject -I$(top_srcdir)/glib $(PYTHON_INCLUDES) $(GLIB_CFLAGS) testhelper_la_LDFLAGS = -module -avoid-version testhelper_la_LIBADD = $(GLIB_LIBS) testhelper_la_SOURCES = \ @@ -274,10 +296,12 @@ testhelper_la_SOURCES = \ test-thread.c \ test-unknown.c -tests = test_gicon.py test_gio.py test_gobject.py test_interface.py \ - test_mainloop.py test_properties.py test_signal.py \ - test_subprocess.py test_unknown.py test_source.py \ - $(am__append_1) +TEST_FILES = test_gobject.py test_interface.py test_mainloop.py \ + test_option.py test_properties.py test_signal.py \ + test_source.py test_subprocess.py test_thread.py test_uris.py \ + $(am__append_3) $(am__append_4) +EXTRA_DIST = compathelper.py runtests.py testmodule.py test-floating.h \ + test-thread.h test-unknown.h $(TEST_FILES) all: all-am .SUFFIXES: @@ -321,6 +345,10 @@ clean-noinstLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done +@ENABLE_INTROSPECTION_FALSE@libgimarshallingtests.la: $(libgimarshallingtests_la_OBJECTS) $(libgimarshallingtests_la_DEPENDENCIES) +@ENABLE_INTROSPECTION_FALSE@ $(AM_V_CCLD)$(libgimarshallingtests_la_LINK) $(am_libgimarshallingtests_la_rpath) $(libgimarshallingtests_la_OBJECTS) $(libgimarshallingtests_la_LIBADD) $(LIBS) +@ENABLE_INTROSPECTION_FALSE@libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES) +@ENABLE_INTROSPECTION_FALSE@ $(AM_V_CCLD)$(libregress_la_LINK) $(am_libregress_la_rpath) $(libregress_la_OBJECTS) $(libregress_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -328,10 +356,12 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-floating.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-thread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-unknown.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhelpermodule.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgimarshallingtests_la-gimarshallingtests.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libregress_la-regress.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhelper_la-test-floating.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhelper_la-test-thread.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhelper_la-test-unknown.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhelper_la-testhelpermodule.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -357,6 +387,54 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libgimarshallingtests_la-gimarshallingtests.lo: $(GI_DATADIR)/tests/gimarshallingtests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgimarshallingtests_la_CFLAGS) $(CFLAGS) -MT libgimarshallingtests_la-gimarshallingtests.lo -MD -MP -MF $(DEPDIR)/libgimarshallingtests_la-gimarshallingtests.Tpo -c -o libgimarshallingtests_la-gimarshallingtests.lo `test -f '$(GI_DATADIR)/tests/gimarshallingtests.c' || echo '$(srcdir)/'`$(GI_DATADIR)/tests/gimarshallingtests.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgimarshallingtests_la-gimarshallingtests.Tpo $(DEPDIR)/libgimarshallingtests_la-gimarshallingtests.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(GI_DATADIR)/tests/gimarshallingtests.c' object='libgimarshallingtests_la-gimarshallingtests.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgimarshallingtests_la_CFLAGS) $(CFLAGS) -c -o libgimarshallingtests_la-gimarshallingtests.lo `test -f '$(GI_DATADIR)/tests/gimarshallingtests.c' || echo '$(srcdir)/'`$(GI_DATADIR)/tests/gimarshallingtests.c + +libregress_la-regress.lo: $(GI_DATADIR)/tests/regress.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libregress_la_CFLAGS) $(CFLAGS) -MT libregress_la-regress.lo -MD -MP -MF $(DEPDIR)/libregress_la-regress.Tpo -c -o libregress_la-regress.lo `test -f '$(GI_DATADIR)/tests/regress.c' || echo '$(srcdir)/'`$(GI_DATADIR)/tests/regress.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libregress_la-regress.Tpo $(DEPDIR)/libregress_la-regress.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(GI_DATADIR)/tests/regress.c' object='libregress_la-regress.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libregress_la_CFLAGS) $(CFLAGS) -c -o libregress_la-regress.lo `test -f '$(GI_DATADIR)/tests/regress.c' || echo '$(srcdir)/'`$(GI_DATADIR)/tests/regress.c + +testhelper_la-testhelpermodule.lo: testhelpermodule.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -MT testhelper_la-testhelpermodule.lo -MD -MP -MF $(DEPDIR)/testhelper_la-testhelpermodule.Tpo -c -o testhelper_la-testhelpermodule.lo `test -f 'testhelpermodule.c' || echo '$(srcdir)/'`testhelpermodule.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/testhelper_la-testhelpermodule.Tpo $(DEPDIR)/testhelper_la-testhelpermodule.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='testhelpermodule.c' object='testhelper_la-testhelpermodule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -c -o testhelper_la-testhelpermodule.lo `test -f 'testhelpermodule.c' || echo '$(srcdir)/'`testhelpermodule.c + +testhelper_la-test-floating.lo: test-floating.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -MT testhelper_la-test-floating.lo -MD -MP -MF $(DEPDIR)/testhelper_la-test-floating.Tpo -c -o testhelper_la-test-floating.lo `test -f 'test-floating.c' || echo '$(srcdir)/'`test-floating.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/testhelper_la-test-floating.Tpo $(DEPDIR)/testhelper_la-test-floating.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-floating.c' object='testhelper_la-test-floating.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -c -o testhelper_la-test-floating.lo `test -f 'test-floating.c' || echo '$(srcdir)/'`test-floating.c + +testhelper_la-test-thread.lo: test-thread.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -MT testhelper_la-test-thread.lo -MD -MP -MF $(DEPDIR)/testhelper_la-test-thread.Tpo -c -o testhelper_la-test-thread.lo `test -f 'test-thread.c' || echo '$(srcdir)/'`test-thread.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/testhelper_la-test-thread.Tpo $(DEPDIR)/testhelper_la-test-thread.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-thread.c' object='testhelper_la-test-thread.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -c -o testhelper_la-test-thread.lo `test -f 'test-thread.c' || echo '$(srcdir)/'`test-thread.c + +testhelper_la-test-unknown.lo: test-unknown.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -MT testhelper_la-test-unknown.lo -MD -MP -MF $(DEPDIR)/testhelper_la-test-unknown.Tpo -c -o testhelper_la-test-unknown.lo `test -f 'test-unknown.c' || echo '$(srcdir)/'`test-unknown.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/testhelper_la-test-unknown.Tpo $(DEPDIR)/testhelper_la-test-unknown.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test-unknown.c' object='testhelper_la-test-unknown.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(testhelper_la_CFLAGS) $(CFLAGS) -c -o testhelper_la-test-unknown.lo `test -f 'test-unknown.c' || echo '$(srcdir)/'`test-unknown.c + mostlyclean-libtool: -rm -f *.lo @@ -467,6 +545,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -563,32 +642,56 @@ uninstall-am: tags uninstall uninstall-am +# This is a hack to make sure a shared library is built +@ENABLE_INTROSPECTION_TRUE@libregress.la: $(libregress_la_OBJECTS) $(libregress_la_DEPENDENCIES) +@ENABLE_INTROSPECTION_TRUE@ $(LINK) -rpath $(pkgpyexecdir) $(libregress_la_LDFLAGS) $(libregress_la_OBJECTS) $(libregress_la_LIBADD) $(LIBS) + +@ENABLE_INTROSPECTION_TRUE@libgimarshallingtests.la: $(libgimarshallingtests_la_OBJECTS) $(libgimarshallingtests_la_DEPENDENCIES) +@ENABLE_INTROSPECTION_TRUE@ $(LINK) -rpath $(pkgpyexecdir) $(libgimarshallingtests_la_LDFLAGS) $(libgimarshallingtests_la_OBJECTS) $(libgimarhallingtests_la_LIBADD) $(LIBS) + +# g-i doesn't ship these as shared libraries anymore; we build them here +@ENABLE_INTROSPECTION_TRUE@Regress-1.0.gir: libregress.la Makefile +@ENABLE_INTROSPECTION_TRUE@ $(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \ +@ENABLE_INTROSPECTION_TRUE@ --namespace=Regress --nsversion=1.0 \ +@ENABLE_INTROSPECTION_TRUE@ --warn-all --warn-error \ +@ENABLE_INTROSPECTION_TRUE@ --library=libregress.la \ +@ENABLE_INTROSPECTION_TRUE@ --libtool="$(top_builddir)/libtool" \ +@ENABLE_INTROSPECTION_TRUE@ --output $@ \ +@ENABLE_INTROSPECTION_TRUE@ $(nodist_libregress_la_SOURCES) +@ENABLE_INTROSPECTION_TRUE@Regress-1.0.typelib: Regress-1.0.gir Makefile +@ENABLE_INTROSPECTION_TRUE@ $(AM_V_GEN) g-ir-compiler $< -o $@ + +@ENABLE_INTROSPECTION_TRUE@GIMarshallingTests-1.0.gir: libgimarshallingtests.la Makefile +@ENABLE_INTROSPECTION_TRUE@ $(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \ +@ENABLE_INTROSPECTION_TRUE@ --namespace=GIMarshallingTests --nsversion=1.0 --symbol-prefix=gi_marshalling_tests \ +@ENABLE_INTROSPECTION_TRUE@ --warn-all --warn-error \ +@ENABLE_INTROSPECTION_TRUE@ --library=libgimarshallingtests.la \ +@ENABLE_INTROSPECTION_TRUE@ --libtool="$(top_builddir)/libtool" \ +@ENABLE_INTROSPECTION_TRUE@ --output $@ \ +@ENABLE_INTROSPECTION_TRUE@ $(nodist_libgimarshallingtests_la_SOURCES) +@ENABLE_INTROSPECTION_TRUE@GIMarshallingTests-1.0.typelib: GIMarshallingTests-1.0.gir Makefile +@ENABLE_INTROSPECTION_TRUE@ $(AM_V_GEN) g-ir-compiler $< -o $@ + # This is a hack to make sure a shared library is built testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES) $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS) -check-local: $(LTLIBRARIES:.la=.so) - $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py $(top_builddir) $(tests) +.la.so: + test -L $@ || $(LN_S) .libs/$@ $@ all: $(LTLIBRARIES:.la=.so) clean-local: - rm -f $(LTLIBRARIES:.la=.so) + rm -f $(LTLIBRARIES:.la=.so) file.txt~ -.la.so: - $(LN_S) .libs/$@ $@ || true +check-local: $(LTLIBRARIES:.la=.so) Regress-1.0.typelib GIMarshallingTests-1.0.typelib + TEST_FILES="$(TEST_FILES)" PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} LD_LIBRARY_PATH=$(builddir)/.libs:$$LD_LIBRARY_PATH GI_TYPELIB_PATH=$(builddir) $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py check.gdb: EXEC_NAME="gdb --args" $(MAKE) check -%.gdb: - EXEC_NAME="gdb --args" TEST_NAMES=$* $(MAKE) check - check.valgrind: - EXEC_NAME="valgrind" $(MAKE) check - -%.valgrind: - EXEC_NAME="valgrind" TEST_NAMES=$* $(MAKE) check + EXEC_NAME="valgrind" G_SLICE=always-malloc G_DEBUG=gc-friendly $(MAKE) check # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/tests/common.py b/tests/common.py deleted file mode 100644 index 1fbeba4..0000000 --- a/tests/common.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import sys - -def importModules(buildDir): - # Be very careful when you change this code, it's - # fragile and the order is really significant - - sys.path.insert(0, buildDir) - sys.path.insert(0, os.path.join(buildDir, 'glib')) - sys.path.insert(0, os.path.join(buildDir, 'gobject')) - sys.path.insert(0, os.path.join(buildDir, 'gio')) - - # testhelper - sys.path.insert(0, os.path.join(buildDir, 'tests')) - sys.argv.append('--g-fatal-warnings') - - testhelper = importModule('testhelper', '.') - glib = importModule('glib', buildDir, 'glib') - gobject = importModule('gobject', buildDir, 'gobject') - gio = importModule('gio', buildDir, 'gio') - - globals().update(locals()) - - os.environ['PYGTK_USE_GIL_STATE_API'] = '' - gobject.threads_init() - -def importModule(module, directory, name=None): - global isDistCheck - - origName = module - if not name: - name = module + '.la' - - try: - obj = __import__(module, {}, {}, '') - except ImportError, e: - raise SystemExit('%s could not be imported: %s' % (origName, e)) - - location = obj.__file__ - - current = os.getcwd() - expected = os.path.abspath(os.path.join(current, location)) - current = os.path.abspath(location) - if current != expected: - raise AssertionError('module %s imported from wrong location. Expected %s, got %s' % ( - module, expected, current)) - return obj diff --git a/tests/compathelper.py b/tests/compathelper.py new file mode 100644 index 0000000..754285c --- /dev/null +++ b/tests/compathelper.py @@ -0,0 +1,50 @@ +import sys + +if sys.version_info >= (3, 0): + ''' + for tests that need to test long values in python 2 + + python 3 does not differentiate between long and int + and does not supply a long keyword + + instead of testing longs by using values such as 10L + test writters should do this: + + from compathelper import _long + _long(10) + ''' + _long = int + + ''' + for tests that need to test string values in python 2 + + python 3 does differentiate between str and bytes + and does not supply a basestring keyword + + any tests that use basestring should do this: + + from compathelper import _basestring + isinstance(_basestring, "hello") + ''' + _basestring = str + + ''' + for tests that need to write to intefaces that take bytes in + python 3 + + python 3 has a seperate bytes type for low level functions like os.write + + python 2 treats these as strings + + any tests that need to write a string of bytes should do something like + this: + + from compathelper import _bytes + os.write(_bytes("hello")) + ''' + + _bytes = lambda s: s.encode() +else: + _long = long + _basestring = basestring + _bytes = str diff --git a/tests/runtests.py b/tests/runtests.py index ea19df5..d99f0cc 100644 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -1,35 +1,28 @@ -#!/usr/bin/env python -import glob -import os -import sys -import unittest - -import common - -program = None -if len(sys.argv) < 2: - raise ValueError('Need at least 2 parameters: runtests.py ' - ' ...') +# -*- Mode: Python -*- -buildDir = sys.argv[1] -files = sys.argv[2:] +import os +import glob -common.importModules(buildDir=buildDir) +import unittest -dir = os.path.split(os.path.abspath(__file__))[0] -os.chdir(dir) -def gettestnames(): - names = map(lambda x: x[:-3], files) - return names +# Load tests. +if 'TEST_NAMES' in os.environ: + names = os.environ['TEST_NAMES'].split() +elif 'TEST_FILES' in os.environ: + names = [] + for filename in os.environ['TEST_FILES'].split(): + names.append(filename[:-3]) +else: + names = [] + for filename in glob.iglob("test_*.py"): + names.append(filename[:-3]) -suite = unittest.TestSuite() loader = unittest.TestLoader() +suite = loader.loadTestsFromNames(names) + -for name in gettestnames(): - if program and program not in name: - continue - suite.addTest(loader.loadTestsFromName(name)) +# Run tests. +runner = unittest.TextTestRunner(verbosity=2) +runner.run(suite) -testRunner = unittest.TextTestRunner() -testRunner.run(suite) diff --git a/tests/test_everything.py b/tests/test_everything.py index 69d1954..6e77a3d 100644 --- a/tests/test_everything.py +++ b/tests/test_everything.py @@ -10,7 +10,8 @@ from sys import getrefcount import cairo from gi.repository import GObject -from gi.repository import Everything +from gi.repository import GLib +from gi.repository import Regress as Everything class TestEverything(unittest.TestCase): @@ -82,9 +83,37 @@ class TestEverything(unittest.TestCase): def test_wrong_type_of_arguments(self): try: Everything.test_int8() - except TypeError, e: + except TypeError: + (e_type, e) = sys.exc_info()[:2] self.assertEquals(e.args, ("test_int8() takes exactly 1 argument(s) (0 given)",)) + def test_gtypes(self): + gchararray_gtype = GObject.type_from_name('gchararray') + gtype = Everything.test_gtype(str) + self.assertEquals(gchararray_gtype, gtype) + gtype = Everything.test_gtype('gchararray') + self.assertEquals(gchararray_gtype, gtype) + gobject_gtype = GObject.GObject.__gtype__ + gtype = Everything.test_gtype(GObject.GObject) + self.assertEquals(gobject_gtype, gtype) + gtype = Everything.test_gtype('GObject') + self.assertEquals(gobject_gtype, gtype) + self.assertRaises(TypeError, Everything.test_gtype, 'invalidgtype') + + class NotARegisteredClass(object): + pass + + self.assertRaises(TypeError, Everything.test_gtype, NotARegisteredClass) + + class ARegisteredClass(GObject.GObject): + __gtype_name__ = 'EverythingTestsARegisteredClass' + + gtype = Everything.test_gtype('EverythingTestsARegisteredClass') + self.assertEquals(ARegisteredClass.__gtype__, gtype) + gtype = Everything.test_gtype(ARegisteredClass) + self.assertEquals(ARegisteredClass.__gtype__, gtype) + self.assertRaises(TypeError, Everything.test_gtype, 'ARegisteredClass') + class TestNullableArgs(unittest.TestCase): def test_in_nullable_hash(self): Everything.test_ghash_null_in(None) @@ -103,7 +132,7 @@ class TestNullableArgs(unittest.TestCase): Everything.test_utf8_null_in(None) def test_in_nullable_object(self): - Everything.test_object_null_in(None) + Everything.func_obj_null_in(None) def test_out_nullable_hash(self): self.assertEqual(None, Everything.test_ghash_null_out()) @@ -119,7 +148,7 @@ class TestNullableArgs(unittest.TestCase): self.assertEqual(None, Everything.test_utf8_null_out()) def test_out_nullable_object(self): - self.assertEqual(None, Everything.test_object_null_out()) + self.assertEqual(None, Everything.TestObj.null_out()) class TestCallbacks(unittest.TestCase): @@ -218,7 +247,7 @@ class TestCallbacks(unittest.TestCase): start_ref_count = getrefcount(ud) for i in range(100): Everything.test_callback_destroy_notify(callback, ud) - + Everything.test_callback_thaw_notifications() end_ref_count = getrefcount(ud) @@ -253,6 +282,7 @@ class TestCallbacks(unittest.TestCase): def callback(): TestCallbacks.called = True + return 42 TestCallbacks.called = False object_.instance_method_callback(callback) @@ -264,6 +294,7 @@ class TestCallbacks(unittest.TestCase): def callbackWithUserData(user_data): TestCallbacks.called = True + return 42 TestCallbacks.called = False obj_ = Everything.TestObj.new_callback(callbackWithUserData, None) @@ -272,3 +303,56 @@ class TestCallbacks(unittest.TestCase): def testCallbackNone(self): # make sure this doesn't assert or crash Everything.test_simple_callback(None) + + +class TestProperties(unittest.TestCase): + + def test_basic(self): + object_ = Everything.TestObj() + + self.assertEquals(object_.props.int, 0) + object_.props.int = 42 + self.assertTrue(isinstance(object_.props.int, int)) + self.assertEquals(object_.props.int, 42) + + self.assertEquals(object_.props.float, 0.0) + object_.props.float = 42.42 + self.assertTrue(isinstance(object_.props.float, float)) + self.assertAlmostEquals(object_.props.float, 42.42, places=5) + + self.assertEquals(object_.props.double, 0.0) + object_.props.double = 42.42 + self.assertTrue(isinstance(object_.props.double, float)) + self.assertAlmostEquals(object_.props.double, 42.42, places=5) + + self.assertEquals(object_.props.string, None) + object_.props.string = 'mec' + self.assertTrue(isinstance(object_.props.string, str)) + self.assertEquals(object_.props.string, 'mec') + + def test_hash_table(self): + object_ = Everything.TestObj() + self.assertEquals(object_.props.hash_table, None) + + object_.props.hash_table = {'mec': 56} + self.assertTrue(isinstance(object_.props.hash_table, dict)) + self.assertEquals(list(object_.props.hash_table.items())[0], ('mec', 56)) + + def test_list(self): + object_ = Everything.TestObj() + self.assertEquals(object_.props.list, []) + + object_.props.list = ['1', '2', '3'] + self.assertTrue(isinstance(object_.props.list, list)) + self.assertEquals(object_.props.list, ['1', '2', '3']) + + def test_boxed(self): + object_ = Everything.TestObj() + self.assertEquals(object_.props.boxed, None) + + boxed = Everything.TestBoxed() + boxed.some_int8 = 42 + object_.props.boxed = boxed + + self.assertTrue(isinstance(object_.props.boxed, Everything.TestBoxed)) + self.assertEquals(object_.props.boxed.some_int8, 42) diff --git a/tests/test_gcancellable.py b/tests/test_gcancellable.py new file mode 100644 index 0000000..f911572 --- /dev/null +++ b/tests/test_gcancellable.py @@ -0,0 +1,15 @@ +# -*- Mode: Python -*- + +import unittest + +import glib +import gio + + +class TestResolver(unittest.TestCase): + def setUp(self): + self.cancellable = gio.Cancellable() + + def test_make_poll_fd(self): + poll = self.cancellable.make_pollfd() + self.failUnless(isinstance(poll, glib.PollFD)) diff --git a/tests/test_gi.py b/tests/test_gi.py index 3444c9d..fa9df70 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -1,20 +1,22 @@ # -*- Mode: Python; py-indent-offset: 4 -*- +# coding=utf-8 # vim: tabstop=4 shiftwidth=4 expandtab +import sys import pygtk pygtk.require("2.0") import unittest from gi.repository import GObject -import sys -sys.path.insert(0, "../") - import gobject from gi.repository import GIMarshallingTests +if sys.version_info < (3, 0): + CONSTANT_UTF8 = "const \xe2\x99\xa5 utf8" +else: + CONSTANT_UTF8 = "const ♥ utf8" -CONSTANT_UTF8 = "const \xe2\x99\xa5 utf8" CONSTANT_NUMBER = 42 @@ -617,9 +619,6 @@ class TestUtf8(unittest.TestCase): self.assertRaises(TypeError, GIMarshallingTests.utf8_none_in, CONSTANT_NUMBER) self.assertRaises(TypeError, GIMarshallingTests.utf8_none_in, None) - def test_utf8_full_in(self): - GIMarshallingTests.utf8_full_in(CONSTANT_UTF8) - def test_utf8_none_out(self): self.assertEquals(CONSTANT_UTF8, GIMarshallingTests.utf8_none_out()) @@ -754,12 +753,6 @@ class TestGArray(unittest.TestCase): def test_garray_utf8_none_in(self): GIMarshallingTests.garray_utf8_none_in(Sequence(['0', '1', '2'])) - def test_garray_utf8_container_in(self): - GIMarshallingTests.garray_utf8_container_in(Sequence(['0', '1', '2'])) - - def test_garray_utf8_full_in(self): - GIMarshallingTests.garray_utf8_full_in(Sequence(['0', '1', '2'])) - def test_garray_utf8_none_out(self): self.assertEquals(['0', '1', '2'], GIMarshallingTests.garray_utf8_none_out()) @@ -804,12 +797,6 @@ class TestGList(unittest.TestCase): def test_glist_utf8_none_in(self): GIMarshallingTests.glist_utf8_none_in(Sequence(('0', '1', '2'))) - def test_glist_utf8_container_in(self): - GIMarshallingTests.glist_utf8_container_in(Sequence(('0', '1', '2'))) - - def test_glist_utf8_full_in(self): - GIMarshallingTests.glist_utf8_full_in(Sequence(('0', '1', '2'))) - def test_glist_utf8_none_out(self): self.assertEquals(['0', '1', '2'], GIMarshallingTests.glist_utf8_none_out()) @@ -854,12 +841,6 @@ class TestGSList(unittest.TestCase): def test_gslist_utf8_none_in(self): GIMarshallingTests.gslist_utf8_none_in(Sequence(('0', '1', '2'))) - def test_gslist_utf8_container_in(self): - GIMarshallingTests.gslist_utf8_container_in(Sequence(('0', '1', '2'))) - - def test_gslist_utf8_full_in(self): - GIMarshallingTests.gslist_utf8_full_in(Sequence(('0', '1', '2'))) - def test_gslist_utf8_none_out(self): self.assertEquals(['0', '1', '2'], GIMarshallingTests.gslist_utf8_none_out()) @@ -905,12 +886,6 @@ class TestGHashTable(unittest.TestCase): def test_ghashtable_utf8_none_in(self): GIMarshallingTests.ghashtable_utf8_none_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'}) - def test_ghashtable_utf8_container_in(self): - GIMarshallingTests.ghashtable_utf8_container_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'}) - - def test_ghashtable_utf8_full_in(self): - GIMarshallingTests.ghashtable_utf8_full_in({'-1': '1', '0': '0', '1': '-1', '2': '-2'}) - def test_ghashtable_utf8_none_out(self): self.assertEquals({'-1': '1', '0': '0', '1': '-1', '2': '-2'}, GIMarshallingTests.ghashtable_utf8_none_out()) @@ -974,8 +949,9 @@ class TestEnum(unittest.TestCase): def test_enum_in(self): GIMarshallingTests.enum_in(GIMarshallingTests.Enum.VALUE3) + GIMarshallingTests.enum_in(42) - self.assertRaises(TypeError, GIMarshallingTests.enum_in, 42) + self.assertRaises(TypeError, GIMarshallingTests.enum_in, 43) self.assertRaises(TypeError, GIMarshallingTests.enum_in, 'GIMarshallingTests.Enum.VALUE3') def test_enum_out(self): @@ -1000,8 +976,9 @@ class TestGEnum(unittest.TestCase): def test_genum_in(self): GIMarshallingTests.genum_in(GIMarshallingTests.GEnum.VALUE3) + GIMarshallingTests.genum_in(42) - self.assertRaises(TypeError, GIMarshallingTests.genum_in, 42) + self.assertRaises(TypeError, GIMarshallingTests.genum_in, 43) self.assertRaises(TypeError, GIMarshallingTests.genum_in, 'GIMarshallingTests.GEnum.VALUE3') def test_genum_out(self): @@ -1076,7 +1053,7 @@ class TestStructure(unittest.TestCase): self.assertEquals(None, struct.pointer) def test_simple_struct_return(self): - struct = GIMarshallingTests.simple_struct_return() + struct = GIMarshallingTests.simple_struct_returnv() self.assertTrue(isinstance(struct, GIMarshallingTests.SimpleStruct)) self.assertEquals(6, struct.long_) @@ -1089,40 +1066,17 @@ class TestStructure(unittest.TestCase): struct.long_ = 6 struct.int8 = 7 - GIMarshallingTests.simple_struct_in(struct) + GIMarshallingTests.SimpleStruct.inv(struct) del struct struct = GIMarshallingTests.NestedStruct() - self.assertRaises(TypeError, GIMarshallingTests.simple_struct_in, struct) + self.assertRaises(TypeError, GIMarshallingTests.SimpleStruct.inv, struct) del struct - self.assertRaises(TypeError, GIMarshallingTests.simple_struct_in, None) - - def test_simple_struct_out(self): - struct = GIMarshallingTests.simple_struct_out() - - self.assertTrue(isinstance(struct, GIMarshallingTests.SimpleStruct)) - self.assertEquals(6, struct.long_) - self.assertEquals(7, struct.int8) - - del struct - - def test_simple_struct_inout(self): - in_struct = GIMarshallingTests.SimpleStruct() - in_struct.long_ = 6 - in_struct.int8 = 7 - - out_struct = GIMarshallingTests.simple_struct_inout(in_struct) - - self.assertTrue(isinstance(out_struct, GIMarshallingTests.SimpleStruct)) - self.assertEquals(7, out_struct.long_) - self.assertEquals(6, out_struct.int8) - - del in_struct - del out_struct + self.assertRaises(TypeError, GIMarshallingTests.SimpleStruct.inv, None) def test_simple_struct_method(self): struct = GIMarshallingTests.SimpleStruct() @@ -1145,7 +1099,7 @@ class TestStructure(unittest.TestCase): del struct def test_pointer_struct_return(self): - struct = GIMarshallingTests.pointer_struct_return() + struct = GIMarshallingTests.pointer_struct_returnv() self.assertTrue(isinstance(struct, GIMarshallingTests.PointerStruct)) self.assertEquals(42, struct.long_) @@ -1156,30 +1110,10 @@ class TestStructure(unittest.TestCase): struct = GIMarshallingTests.PointerStruct() struct.long_ = 42 - GIMarshallingTests.pointer_struct_in(struct) - - del struct - - def test_pointer_struct_out(self): - struct = GIMarshallingTests.pointer_struct_out() - - self.assertTrue(isinstance(struct, GIMarshallingTests.PointerStruct)) - self.assertEquals(42, struct.long_) + struct.inv() del struct - def test_pointer_struct_inout(self): - in_struct = GIMarshallingTests.PointerStruct() - in_struct.long_ = 42 - - out_struct = GIMarshallingTests.pointer_struct_inout(in_struct) - - self.assertTrue(isinstance(out_struct, GIMarshallingTests.PointerStruct)) - self.assertEquals(0, out_struct.long_) - - del in_struct - del out_struct - def test_boxed_struct(self): self.assertTrue(issubclass(GIMarshallingTests.BoxedStruct, GObject.GBoxed)) @@ -1207,7 +1141,7 @@ class TestStructure(unittest.TestCase): del struct def test_boxed_struct_return(self): - struct = GIMarshallingTests.boxed_struct_return() + struct = GIMarshallingTests.boxed_struct_returnv() self.assertTrue(isinstance(struct, GIMarshallingTests.BoxedStruct)) self.assertEquals(42, struct.long_) @@ -1219,7 +1153,7 @@ class TestStructure(unittest.TestCase): struct = GIMarshallingTests.BoxedStruct() struct.long_ = 42 - GIMarshallingTests.boxed_struct_in(struct) + struct.inv() del struct @@ -1255,7 +1189,7 @@ class TestStructure(unittest.TestCase): del new_union def test_union_return(self): - union = GIMarshallingTests.union_return() + union = GIMarshallingTests.union_returnv() self.assertTrue(isinstance(union, GIMarshallingTests.Union)) self.assertEquals(42, union.long_) @@ -1266,30 +1200,10 @@ class TestStructure(unittest.TestCase): union = GIMarshallingTests.Union() union.long_ = 42 - GIMarshallingTests.union_in(union) + union.inv() del union - def test_union_out(self): - union = GIMarshallingTests.union_out() - - self.assertTrue(isinstance(union, GIMarshallingTests.Union)) - self.assertEquals(42, union.long_) - - del union - - def test_union_inout(self): - in_union = GIMarshallingTests.Union() - in_union.long_ = 42 - - out_union = GIMarshallingTests.union_inout(in_union) - - self.assertTrue(isinstance(out_union, GIMarshallingTests.Union)) - self.assertEquals(0, out_union.long_) - - del in_union - del out_union - def test_union_method(self): union = GIMarshallingTests.Union() union.long_ = 42 @@ -1365,49 +1279,44 @@ class TestGObject(unittest.TestCase): # self.assertEquals(object_.int_, 42) def test_object_none_return(self): - object_ = GIMarshallingTests.object_none_return() + object_ = GIMarshallingTests.Object.none_return() self.assertTrue(isinstance(object_, GIMarshallingTests.Object)) self.assertEquals(object_.__grefcount__, 2) def test_object_full_return(self): - object_ = GIMarshallingTests.object_full_return() + object_ = GIMarshallingTests.Object.full_return() self.assertTrue(isinstance(object_, GIMarshallingTests.Object)) self.assertEquals(object_.__grefcount__, 1) def test_object_none_in(self): object_ = GIMarshallingTests.Object(int = 42) - GIMarshallingTests.object_none_in(object_) + GIMarshallingTests.Object.none_in(object_) self.assertEquals(object_.__grefcount__, 1) object_ = GIMarshallingTests.SubObject(int = 42) - GIMarshallingTests.object_none_in(object_) + GIMarshallingTests.Object.none_in(object_) object_ = GObject.GObject() - self.assertRaises(TypeError, GIMarshallingTests.object_none_in, object_) - - self.assertRaises(TypeError, GIMarshallingTests.object_none_in, None) + self.assertRaises(TypeError, GIMarshallingTests.Object.none_in, object_) - def test_object_full_in(self): - object_ = GIMarshallingTests.Object(int = 42) - GIMarshallingTests.object_full_in(object_) - self.assertEquals(object_.__grefcount__, 1) + self.assertRaises(TypeError, GIMarshallingTests.Object.none_in, None) def test_object_none_out(self): - object_ = GIMarshallingTests.object_none_out() + object_ = GIMarshallingTests.Object.none_out() self.assertTrue(isinstance(object_, GIMarshallingTests.Object)) self.assertEquals(object_.__grefcount__, 2) - new_object = GIMarshallingTests.object_none_out() + new_object = GIMarshallingTests.Object.none_out() self.assertTrue(new_object is object_) def test_object_full_out(self): - object_ = GIMarshallingTests.object_full_out() + object_ = GIMarshallingTests.Object.full_out() self.assertTrue(isinstance(object_, GIMarshallingTests.Object)) self.assertEquals(object_.__grefcount__, 1) def test_object_none_inout(self): object_ = GIMarshallingTests.Object(int = 42) - new_object = GIMarshallingTests.object_none_inout(object_) + new_object = GIMarshallingTests.Object.none_inout(object_) self.assertTrue(isinstance(new_object, GIMarshallingTests.Object)) @@ -1416,20 +1325,20 @@ class TestGObject(unittest.TestCase): self.assertEquals(object_.__grefcount__, 1) self.assertEquals(new_object.__grefcount__, 2) - new_new_object = GIMarshallingTests.object_none_inout(object_) + new_new_object = GIMarshallingTests.Object.none_inout(object_) self.assertTrue(new_new_object is new_object) - GIMarshallingTests.object_none_inout(GIMarshallingTests.SubObject(int = 42)) + GIMarshallingTests.Object.none_inout(GIMarshallingTests.SubObject(int = 42)) def test_object_full_inout(self): object_ = GIMarshallingTests.Object(int = 42) - new_object = GIMarshallingTests.object_full_inout(object_) + new_object = GIMarshallingTests.Object.full_inout(object_) self.assertTrue(isinstance(new_object, GIMarshallingTests.Object)) self.assertFalse(object_ is new_object) - self.assertEquals(object_.__grefcount__, 1) + self.assertEquals(object_.__grefcount__, 2) self.assertEquals(new_object.__grefcount__, 1) # FIXME: Doesn't actually return the same object. @@ -1573,7 +1482,7 @@ class TestOverrides(unittest.TestCase): del struct # Test that the overrides wrapper has been registered. - struct = GIMarshallingTests.overrides_struct_return() + struct = GIMarshallingTests.overrides_struct_returnv() self.assertTrue(isinstance(struct, GIMarshallingTests.OverridesStruct)) @@ -1594,7 +1503,7 @@ class TestOverrides(unittest.TestCase): self.assertEquals(6, object_.method()) # Test that the overrides wrapper has been registered. - object_ = GIMarshallingTests.overrides_object_return() + object_ = GIMarshallingTests.OverridesObject.returnv() self.assertTrue(isinstance(object_, GIMarshallingTests.OverridesObject)) diff --git a/tests/test_gicon.py b/tests/test_gicon.py index 5ce7ece..b9af6ff 100644 --- a/tests/test_gicon.py +++ b/tests/test_gicon.py @@ -3,7 +3,8 @@ import os import unittest -from common import gio, glib +import glib +import gio class TestIcon(unittest.TestCase): diff --git a/tests/test_gio.py b/tests/test_gio.py index feafc70..7c8251e 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -3,7 +3,8 @@ import os import unittest -from common import gio, glib +import glib +import gio class TestFile(unittest.TestCase): diff --git a/tests/test_gobject.py b/tests/test_gobject.py index d91f3ad..f3cdf29 100644 --- a/tests/test_gobject.py +++ b/tests/test_gobject.py @@ -2,7 +2,8 @@ import unittest -from common import gobject, testhelper +import gobject +import testhelper class TestGObjectAPI(unittest.TestCase): diff --git a/tests/test_gresolver.py b/tests/test_gresolver.py new file mode 100644 index 0000000..ef8585c --- /dev/null +++ b/tests/test_gresolver.py @@ -0,0 +1,65 @@ +# -*- Mode: Python -*- + +import unittest + +import glib +import gio + + +class TestResolver(unittest.TestCase): + def setUp(self): + self.resolver = gio.resolver_get_default() + + def test_resolver_lookup_by_name(self): + addresses = self.resolver.lookup_by_name("pygtk.org", cancellable=None) + self.failUnless(isinstance(addresses[0], gio.InetAddress)) + + def test_resolver_lookup_by_address(self): + address = gio.inet_address_new_from_string("8.8.8.8") + dns = self.resolver.lookup_by_address(address, cancellable=None) + self.failUnlessEqual(dns, "google-public-dns-a.google.com") + + def test_resolver_lookup_by_name_async(self): + def callback(resolver, result): + try: + addresses = resolver.lookup_by_name_finish(result) + self.failUnless(isinstance(addresses[0], gio.InetAddress)) + finally: + loop.quit() + + self.resolver.lookup_by_name_async(callback, "pygtk.org") + + loop = glib.MainLoop() + loop.run() + + def test_resolver_lookup_by_address_async(self): + def callback(resolver, result): + try: + dns = resolver.lookup_by_address_finish(result) + self.failUnlessEqual(dns, "google-public-dns-b.google.com") + finally: + loop.quit() + + address = gio.inet_address_new_from_string("8.8.4.4") + self.resolver.lookup_by_address_async(callback, address) + + loop = glib.MainLoop() + loop.run() + + def test_resolver_lookup_service(self): + targets = self.resolver.lookup_service("xmpp-client", "tcp", "google.com") + self.failUnless(isinstance(targets[0], gio.SrvTarget)) + + def test_resolver_lookup_service_async(self): + def callback(resolver, result): + try: + targets = resolver.lookup_service_finish(result) + self.failUnless(isinstance(targets[0], gio.SrvTarget)) + finally: + loop.quit() + + self.resolver.lookup_service_async(callback, "xmpp-client", "tcp", "google.com") + + loop = glib.MainLoop() + loop.run() + diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py new file mode 100644 index 0000000..627f6fd --- /dev/null +++ b/tests/test_gsocket.py @@ -0,0 +1,126 @@ +# -*- Mode: Python -*- + +import os +import unittest + +import glib +import gobject +import gio + + +class TestSocket(unittest.TestCase): + def setUp(self): + self.sock = gio.Socket(gio.SOCKET_FAMILY_IPV4, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + def test_socket_condition_check(self): + check = self.sock.condition_check(glib.IO_OUT) + self.failUnless(isinstance(check, gobject.GFlags)) + self.failUnlessEqual(check, glib.IO_OUT | glib.IO_HUP) + + def test_socket_condition_wait(self): + res = self.sock.condition_wait(glib.IO_OUT) + self.failUnless(res) + + def tearDown(self): + self.sock.close() + +class TestSocketAddress(unittest.TestCase): + def test_socket_address_enumerator_next_async(self): + def callback(enumerator, result): + try: + address = enumerator.next_finish(result) + self.failUnless(isinstance(address, gio.SocketAddress)) + finally: + loop.quit() + + socket = gio.NetworkAddress("www.pygtk.org", 80) + enumerator = socket.enumerate() + enumerator.next_async(callback) + + loop = glib.MainLoop() + loop.run() + +class TestSocketListener(unittest.TestCase): + def test_socket_listener_add_address(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + effective = listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + self.failUnless(isinstance(effective, gio.InetSocketAddress)) + + def test_socket_listener_accept(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + connection, source = listener.accept(cancellable=None) + self.failUnless(isinstance(connection, gio.TcpConnection)) + + def test_socket_listener_accept_socket(self): + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, gio.SOCKET_TYPE_STREAM, gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + socket, source = listener.accept_socket(cancellable=None) + self.failUnless(isinstance(socket, gio.Socket)) + + def test_socket_listener_accept_async(self): + def callback(listener, result): + try: + connection, source = listener.accept_finish(result) + self.failUnless(isinstance(connection, gio.TcpConnection)) + finally: + loop.quit() + + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + listener.accept_async(callback) + + loop = glib.MainLoop() + loop.run() + + def test_socket_listener_accept_socket_async(self): + def callback(listener, result): + try: + socket, source = listener.accept_socket_finish(result) + self.failUnless(isinstance(socket, gio.Socket)) + finally: + loop.quit() + + address = gio.inet_address_new_from_string("127.0.0.1") + inetsock = gio.InetSocketAddress(address, 1024) + + listener = gio.SocketListener() + listener.add_address(inetsock, + gio.SOCKET_TYPE_STREAM, + gio.SOCKET_PROTOCOL_TCP) + + client = gio.SocketClient() + client.connect_to_host("127.0.0.1:1024", 1024) + + listener.accept_socket_async(callback) + + loop = glib.MainLoop() + loop.run() diff --git a/tests/test_interface.py b/tests/test_interface.py index d959791..fbc0586 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -1,6 +1,10 @@ +# -*- Mode: Python -*- + import unittest -from common import gobject, testhelper +import gobject +import testhelper + GUnknown = gobject.type_from_name("TestUnknown") Unknown = GUnknown.pytype diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py index 95e5f78..80e2aec 100644 --- a/tests/test_mainloop.py +++ b/tests/test_mainloop.py @@ -1,12 +1,13 @@ -#!/usr/bin/env python +# -*- Mode: Python -*- -import exceptions import os import sys import select import unittest -from common import glib +import glib + +from compathelper import _bytes class TestMainLoop(unittest.TestCase): def testExceptionHandling(self): @@ -27,11 +28,11 @@ class TestMainLoop(unittest.TestCase): glib.child_watch_add(pid, child_died, loop) os.close(pipe_r) - os.write(pipe_w, "Y") + os.write(pipe_w, _bytes("Y")) os.close(pipe_w) def excepthook(type, value, traceback): - assert type is exceptions.Exception + assert type is Exception assert value.args[0] == "deadbabe" sys.excepthook = excepthook @@ -48,6 +49,3 @@ class TestMainLoop(unittest.TestCase): # sys.excepthook = sys.__excepthook__ assert not got_exception - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_option.py b/tests/test_option.py new file mode 100644 index 0000000..a6ecc98 --- /dev/null +++ b/tests/test_option.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python + +import unittest +import sys + +# py3k has StringIO in a different module +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + +from glib.option import OptionParser, OptionGroup, OptionValueError, \ + make_option, BadOptionError + +from compathelper import _bytes + +class TestOption(unittest.TestCase): + EXCEPTION_MESSAGE = "This callback fails" + + def setUp(self): + self.parser = OptionParser("NAMES...", + description="Option unit test") + self.parser.add_option("-t", "--test", help="Unit test option", + action="store_false", dest="test", default=True) + self.parser.add_option("--g-fatal-warnings", + action="store_true", + dest="fatal_warnings", + help="dummy"), + + def _create_group(self): + def option_callback(option, opt, value, parser): + raise Exception(self.EXCEPTION_MESSAGE) + + group = OptionGroup( + "unittest", "Unit test options", "Show all unittest options", + option_list = [ + make_option("-f", "-u", "--file", "--unit-file", + type="filename", + dest="unit_file", + help="Unit test option"), + make_option("--test-integer", + type="int", + dest="test_integer", + help="Unit integer option"), + make_option("--callback-failure-test", + action="callback", + callback=option_callback, + dest="test_integer", + help="Unit integer option"), + ]) + group.add_option("-t", "--test", + action="store_false", + dest="test", + default=True, + help="Unit test option") + self.parser.add_option_group(group) + return group + + def testParseArgs(self): + options, args = self.parser.parse_args( + ["test_option.py"]) + self.failIf(args) + + options, args = self.parser.parse_args( + ["test_option.py", "foo"]) + self.assertEquals(args, ["foo"]) + + options, args = self.parser.parse_args( + ["test_option.py", "foo", "bar"]) + self.assertEquals(args, ["foo", "bar"]) + + def testParseArgsDoubleDash(self): + options, args = self.parser.parse_args( + ["test_option.py", "--", "-xxx"]) + #self.assertEquals(args, ["-xxx"]) + + def testParseArgs(self): + options, args = self.parser.parse_args() + + def testParseArgsGroup(self): + group = self._create_group() + + options, args = self.parser.parse_args( + ["test_option.py", "--test", "-f", "test"]) + + self.failIf(options.test) + self.assertEqual(options.unit_file, "test") + + self.failUnless(group.values.test) + self.failIf(self.parser.values.test) + self.assertEqual(group.values.unit_file, "test") + self.failIf(args) + + def testOptionValueError(self): + self._create_group() + self.assertRaises(OptionValueError, self.parser.parse_args, + ["test_option.py", "--test-integer=text"]) + + def testBadOptionError(self): + self.assertRaises(BadOptionError, + self.parser.parse_args, + ["test_option.py", "--unknwon-option"]) + + def testOptionGroupConstructor(self): + self.assertRaises(TypeError, OptionGroup) + + def testStandardError(self): + self._create_group() + sio = StringIO() + old_stderr = sys.stderr + sys.stderr = sio + try: + self.parser.parse_args( + ["test_option.py", "--callback-failure-test"]) + finally: + sys.stderr = old_stderr + + assert (sio.getvalue().split('\n')[-2] == + "Exception: " + self.EXCEPTION_MESSAGE) + diff --git a/tests/test_overrides.py b/tests/test_overrides.py index 0a66587..b1e3617 100644 --- a/tests/test_overrides.py +++ b/tests/test_overrides.py @@ -9,11 +9,36 @@ import unittest import sys sys.path.insert(0, "../") +from gi.repository import GLib from gi.repository import GObject from gi.repository import Gdk from gi.repository import Gtk import gi.overrides as overrides +class TestGLib(unittest.TestCase): + + def test_gvariant(self): + variant = GLib.Variant('i', 42) + self.assertTrue(isinstance(variant, GLib.Variant)) + self.assertEquals(variant.get_int32(), 42) + + variant = GLib.Variant('(ss)', 'mec', 'mac') + self.assertTrue(isinstance(variant, GLib.Variant)) + self.assertTrue(isinstance(variant.get_child_value(0), GLib.Variant)) + self.assertTrue(isinstance(variant.get_child_value(1), GLib.Variant)) + self.assertEquals(variant.get_child_value(0).get_string(), 'mec') + self.assertEquals(variant.get_child_value(1).get_string(), 'mac') + + variant = GLib.Variant('a{si}', {'key1': 1, 'key2': 2}) + self.assertTrue(isinstance(variant, GLib.Variant)) + self.assertTrue(isinstance(variant.get_child_value(0), GLib.Variant)) + self.assertTrue(isinstance(variant.get_child_value(1), GLib.Variant)) + # Looks like order is not preserved + self.assertEquals(variant.get_child_value(1).get_child_value(0).get_string(), 'key1') + self.assertEquals(variant.get_child_value(1).get_child_value(1).get_int32(), 1) + self.assertEquals(variant.get_child_value(0).get_child_value(0).get_string(), 'key2') + self.assertEquals(variant.get_child_value(0).get_child_value(1).get_int32(), 2) + class TestGdk(unittest.TestCase): def test_color(self): @@ -22,6 +47,16 @@ class TestGdk(unittest.TestCase): self.assertEquals(color.green, 200) self.assertEquals(color.blue, 300) + def test_event(self): + event = Gdk.Event.new(Gdk.EventType.CONFIGURE) + self.assertEquals(event.type, Gdk.EventType.CONFIGURE) + self.assertEquals(event.send_event, 0) + + event = Gdk.Event.new(Gdk.EventType.DRAG_MOTION) + event.x_root, event.y_root = 0, 5 + self.assertEquals(event.x_root, 0) + self.assertEquals(event.y_root, 5) + class TestGtk(unittest.TestCase): def test_uimanager(self): self.assertEquals(Gtk.UIManager, overrides.Gtk.UIManager) @@ -156,32 +191,30 @@ class TestGtk(unittest.TestCase): button = dialog.get_widget_for_response (Gtk.ResponseType.CLOSE) self.assertEquals(Gtk.STOCK_CLOSE, button.get_label()) - def test_tree_api(self): + class TestClass(GObject.GObject): + __gtype_name__ = "GIOverrideTreeAPITest" + + def __init__(self, tester, int_value, string_value): + super(TestGtk.TestClass, self).__init__() + self.tester = tester + self.int_value = int_value + self.string_value = string_value + + def check(self, int_value, string_value): + self.tester.assertEquals(int_value, self.int_value) + self.tester.assertEquals(string_value, self.string_value) + + def test_tree_store(self): self.assertEquals(Gtk.TreeStore, overrides.Gtk.TreeStore) self.assertEquals(Gtk.ListStore, overrides.Gtk.ListStore) self.assertEquals(Gtk.TreeModel, overrides.Gtk.TreeModel) self.assertEquals(Gtk.TreeViewColumn, overrides.Gtk.TreeViewColumn) - class TestClass(GObject.GObject): - __gtype_name__ = "GIOverrideTreeAPITest" - - def __init__(self, tester, int_value, string_value): - super(TestClass, self).__init__() - self.tester = tester - self.int_value = int_value - self.string_value = string_value - - def check(self, int_value, string_value): - self.tester.assertEquals(int_value, self.int_value) - self.tester.assertEquals(string_value, self.string_value) - - # check TreeStore - # FIXME: we should be able to pass strings like 'TestClass' - tree_store = Gtk.TreeStore(int, str, TestClass) + tree_store = Gtk.TreeStore(int, 'gchararray', TestGtk.TestClass) parent = None - for i in xrange(100): + for i in range(100): label = 'this is child #%d' % i - testobj = TestClass(self, i, label) + testobj = TestGtk.TestClass(self, i, label) parent = tree_store.append(parent, (i, label, testobj)) # len gets the number of children in the root node @@ -204,12 +237,11 @@ class TestGtk(unittest.TestCase): self.assertEquals(i, 99) - # check ListStore - # FIXME: we should be able to pass strings like 'TestClass' - list_store = Gtk.ListStore(int, str, TestClass) - for i in xrange(100): + def test_list_store(self): + list_store = Gtk.ListStore(int, str, 'GIOverrideTreeAPITest') + for i in range(100): label = 'this is row #%d' % i - testobj = TestClass(self, i, label) + testobj = TestGtk.TestClass(self, i, label) parent = list_store.append((i, label, testobj)) self.assertEquals(len(list_store), 100) @@ -227,7 +259,7 @@ class TestGtk(unittest.TestCase): self.assertEquals(i, 99) - # check to see that we can instantiate a TreeViewColumn + def test_tree_view_column(self): cell = Gtk.CellRendererText() column = Gtk.TreeViewColumn(title='This is just a test', cell_renderer=cell, @@ -256,3 +288,13 @@ class TestGtk(unittest.TestCase): text = buffer.get_text(start, end, False) self.assertEquals(text, 'Hello Jane Hello Bob') + + def test_buttons(self): + self.assertEquals(Gtk.Button, overrides.Gtk.Button) + + # test Gtk.Button + button = Gtk.Button() + button = Gtk.Button(stock=Gtk.STOCK_CLOSE) + self.assertEquals(Gtk.STOCK_CLOSE, button.get_label()) + self.assertTrue(button.get_use_stock()) + self.assertTrue(button.get_use_underline()) diff --git a/tests/test_properties.py b/tests/test_properties.py index ccfcb34..19e1136 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -1,4 +1,5 @@ +import sys import struct import unittest @@ -12,6 +13,8 @@ from gobject.constants import \ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \ G_MAXULONG +from compathelper import _long + class PropertyObject(GObject): normal = gobject.property(type=str) construct = gobject.property( @@ -80,12 +83,12 @@ class TestProperties(unittest.TestCase): def testUint64(self): obj = new(PropertyObject) self.assertEqual(obj.props.uint64, 0) - obj.props.uint64 = 1L - self.assertEqual(obj.props.uint64, 1L) + obj.props.uint64 = _long(1) + self.assertEqual(obj.props.uint64, _long(1)) obj.props.uint64 = 1 - self.assertEqual(obj.props.uint64, 1L) + self.assertEqual(obj.props.uint64, _long(1)) - self.assertRaises((TypeError, OverflowError), obj.set_property, "uint64", -1L) + self.assertRaises((TypeError, OverflowError), obj.set_property, "uint64", _long(-1)) self.assertRaises((TypeError, OverflowError), obj.set_property, "uint64", -1) def testUInt64DefaultValue(self): @@ -93,10 +96,11 @@ class TestProperties(unittest.TestCase): class TimeControl(GObject): __gproperties__ = { 'time': (TYPE_UINT64, 'Time', 'Time', - 0L, (1<<64) - 1, 0L, + _long(0), (1<<64) - 1, _long(0), PARAM_READABLE) } - except OverflowError, ex: + except OverflowError: + (etype, ex) = sys.exc_info()[2:] self.fail(str(ex)) def testRange(self): @@ -182,7 +186,7 @@ class TestProperty(unittest.TestCase): str = gobject.property(type=str) int = gobject.property(type=int) float = gobject.property(type=float) - long = gobject.property(type=long) + long = gobject.property(type=_long) self.failUnless(hasattr(C.props, 'str')) self.failUnless(hasattr(C.props, 'int')) @@ -202,9 +206,9 @@ class TestProperty(unittest.TestCase): o.float = 3.14 self.assertEqual(o.float, 3.14) - self.assertEqual(o.long, 0L) - o.long = 100L - self.assertEqual(o.long, 100L) + self.assertEqual(o.long, _long(0)) + o.long = _long(100) + self.assertEqual(o.long, _long(100)) def testCustomGetter(self): class C(gobject.GObject): diff --git a/tests/test_signal.py b/tests/test_signal.py index 96e0731..d68cb5b 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -4,7 +4,9 @@ import gc import unittest import sys -from common import gobject, testhelper +import gobject +import testhelper +from compathelper import _long class C(gobject.GObject): __gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, @@ -302,7 +304,7 @@ class SigPropClass(gobject.GObject): if pspec.name == 'foo': self._foo = value else: - raise AttributeError, 'unknown property %s' % pspec.name + raise AttributeError('unknown property %s' % pspec.name) try: self.emit("my-signal", 1) except TypeError: @@ -326,7 +328,7 @@ class CM(gobject.GObject): test1=(f, None, ()), test2=(l, None, (str,)), test3=(l, int, (double,)), - test4=(f, None, (bool, long, float, double, int, uint, ulong)), + test4=(f, None, (bool, _long, float, double, int, uint, ulong)), test_float=(l, float, (float,)), test_double=(l, double, (double, )), test_string=(l, str, (str, )), @@ -349,7 +351,7 @@ class _TestCMarshaller: self.assertEqual(rv, 20) def testTest4(self): - self.obj.emit("test4", True, 10L, 3.14, 1.78, 20, 30L, 31L) + self.obj.emit("test4", True, _long(10), 3.14, 1.78, 20, _long(30), _long(31)) def testTestReturnFloat(self): rv = self.obj.emit("test-float", 1.234) @@ -371,9 +373,9 @@ if 'generic-c-marshaller' in gobject.features: class TestCMarshaller(_TestCMarshaller, unittest.TestCase): pass else: - print - print '** WARNING: LIBFFI disabled, not testing' - print + print() + print('** WARNING: LIBFFI disabled, not testing') + print() # Test for 374653 class TestPyGValue(unittest.TestCase): diff --git a/tests/test_source.py b/tests/test_source.py index abe2f69..339fb32 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python +# -*- Mode: Python -*- import unittest -from common import glib +import glib class Idle(glib.Idle): @@ -92,8 +92,8 @@ class TestSource(unittest.TestCase): class TestTimeout(unittest.TestCase): def test504337(self): - timeout_source = glib.Timeout(20) - idle_source = glib.Idle() + timeout_source = glib.Timeout(20) + idle_source = glib.Idle() if __name__ == '__main__': diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 1522edb..c90d1d6 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -3,7 +3,7 @@ import sys import unittest -from common import glib +import glib class TestProcess(unittest.TestCase): @@ -22,6 +22,3 @@ class TestProcess(unittest.TestCase): glib.child_watch_add(pid, self._child_watch_cb, 12345) self.loop.run() self.assertEqual(self.data, 12345) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_thread.py b/tests/test_thread.py new file mode 100644 index 0000000..be746a4 --- /dev/null +++ b/tests/test_thread.py @@ -0,0 +1,29 @@ +# -*- Mode: Python -*- + +import unittest + +import glib +import testhelper + + +class TestThread(unittest.TestCase): + def setUp(self): + self.main = glib.MainLoop() + + def from_thread_cb(self, test, enum): + assert test == self.obj + assert int(enum) == 0 + assert type(enum) != int + + def idle_cb(self): + self.obj = testhelper.get_test_thread() + self.obj.connect('from-thread', self.from_thread_cb) + self.obj.emit('emit-signal') + + def testExtensionModule(self): + glib.idle_add(self.idle_cb) + glib.timeout_add(50, self.timeout_cb) + self.main.run() + + def timeout_cb(self): + self.main.quit() diff --git a/tests/test_unknown.py b/tests/test_unknown.py deleted file mode 100644 index d65bb89..0000000 --- a/tests/test_unknown.py +++ /dev/null @@ -1,15 +0,0 @@ - -import unittest - -from common import gobject, testhelper - -TestInterface = gobject.GType.from_name('TestInterface') - - -class TestUnknown(unittest.TestCase): - def testFoo(self): - obj = testhelper.get_unknown() - TestUnknownGType = gobject.GType.from_name('TestUnknown') - TestUnknown = gobject.new(TestUnknownGType).__class__ - assert isinstance(obj, testhelper.Interface) - assert isinstance(obj, TestUnknown) diff --git a/tests/test_uris.py b/tests/test_uris.py new file mode 100644 index 0000000..ee24215 --- /dev/null +++ b/tests/test_uris.py @@ -0,0 +1,15 @@ +import unittest + +import glib + +class TestUris(unittest.TestCase): + def testExtractUris(self): + uri_list_text = "# urn:isbn:0-201-08372-8\n" + \ + "http://www.huh.org/books/foo.html\n" + \ + "http://www.huh.org/books/foo.pdf\n" + \ + "ftp://ftp.foo.org/books/foo.txt\n" + uri_list = glib.uri_list_extract_uris(uri_list_text) + assert uri_list[0] == "http://www.huh.org/books/foo.html" + assert uri_list[1] == "http://www.huh.org/books/foo.pdf" + assert uri_list[2] == "ftp://ftp.foo.org/books/foo.txt" + diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c index 21679bc..5610a5d 100644 --- a/tests/testhelpermodule.c +++ b/tests/testhelpermodule.c @@ -5,6 +5,8 @@ #include "test-unknown.h" #include "test-floating.h" +#include + static PyTypeObject *_PyGObject_Type; #define PyGObject_Type (*_PyGObject_Type) @@ -83,7 +85,7 @@ _wrap_test_g_object_new (PyObject * self) PyObject *rv; obj = g_object_new(g_type_from_name("PyGObject"), NULL); - rv = PyInt_FromLong(obj->ref_count); /* should be == 2 at this point */ + rv = PYGLIB_PyLong_FromLong(obj->ref_count); /* should be == 2 at this point */ g_object_unref(obj); return rv; } @@ -112,53 +114,7 @@ static const PyMethodDef _PyTestInterface_methods[] = { }; /* TestInterface */ -PyTypeObject PyTestInterface_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "test.Interface", /* tp_name */ - sizeof(PyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)0, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - (PyNumberMethods*)0, /* tp_as_number */ - (PySequenceMethods*)0, /* tp_as_sequence */ - (PyMappingMethods*)0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc)0, /* tp_getattro */ - (setattrofunc)0, /* tp_setattro */ - (PyBufferProcs*)0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - NULL, /* Documentation string */ - (traverseproc)0, /* tp_traverse */ - (inquiry)0, /* tp_clear */ - (richcmpfunc)0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - (struct PyMethodDef*)_PyTestInterface_methods, /* tp_methods */ - (struct PyMemberDef*)0, /* tp_members */ - (struct PyGetSetDef*)0, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - (descrgetfunc)0, /* tp_descr_get */ - (descrsetfunc)0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)0, /* tp_init */ - (allocfunc)0, /* tp_alloc */ - (newfunc)0, /* tp_new */ - (freefunc)0, /* tp_free */ - (inquiry)0 /* tp_is_gc */ - - - -}; +PYGLIB_DEFINE_TYPE("test.Interface", PyTestInterface_Type, PyObject); static PyObject * _wrap_TestInterface__do_iface_method(PyObject *cls, PyObject *args, PyObject *kwargs) @@ -183,51 +139,7 @@ _wrap_TestInterface__do_iface_method(PyObject *cls, PyObject *args, PyObject *kw return Py_None; } -PyTypeObject PyTestUnknown_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "testhelper.Unknown", /* tp_name */ - sizeof(PyGObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)0, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - (PyNumberMethods*)0, /* tp_as_number */ - (PySequenceMethods*)0, /* tp_as_sequence */ - (PyMappingMethods*)0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc)0, /* tp_getattro */ - (setattrofunc)0, /* tp_setattro */ - (PyBufferProcs*)0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* Documentation string */ - (traverseproc)0, /* tp_traverse */ - (inquiry)0, /* tp_clear */ - (richcmpfunc)0, /* tp_richcompare */ - offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - (struct PyMethodDef*)0, /* tp_methods */ - (struct PyMemberDef*)0, /* tp_members */ - (struct PyGetSetDef*)0, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - (descrgetfunc)0, /* tp_descr_get */ - (descrsetfunc)0, /* tp_descr_set */ - offsetof(PyGObject, inst_dict), /* tp_dictoffset */ - (initproc)0, /* tp_init */ - (allocfunc)0, /* tp_alloc */ - (newfunc)0, /* tp_new */ - (freefunc)0, /* tp_free */ - (inquiry)0 /* tp_is_gc */ -}; - +PYGLIB_DEFINE_TYPE("testhelper.Unknown", PyTestUnknown_Type, PyGObject); static void _wrap_TestInterface__proxy_do_iface_method(TestInterface *self) @@ -313,98 +225,10 @@ static const GInterfaceInfo __TestInterface__iinfo = { }; /* TestFloatingWithSinkFunc */ - -PyTypeObject PyTestFloatingWithSinkFunc_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "testhelper.FloatingWithSinkFunc", /* tp_name */ - sizeof(PyGObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)0, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - (PyNumberMethods*)0, /* tp_as_number */ - (PySequenceMethods*)0, /* tp_as_sequence */ - (PyMappingMethods*)0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc)0, /* tp_getattro */ - (setattrofunc)0, /* tp_setattro */ - (PyBufferProcs*)0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* Documentation string */ - (traverseproc)0, /* tp_traverse */ - (inquiry)0, /* tp_clear */ - (richcmpfunc)0, /* tp_richcompare */ - offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - (struct PyMethodDef*)0, /* tp_methods */ - (struct PyMemberDef*)0, /* tp_members */ - (struct PyGetSetDef*)0, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - (descrgetfunc)0, /* tp_descr_get */ - (descrsetfunc)0, /* tp_descr_set */ - offsetof(PyGObject, inst_dict), /* tp_dictoffset */ - (initproc)0, /* tp_init */ - (allocfunc)0, /* tp_alloc */ - (newfunc)0, /* tp_new */ - (freefunc)0, /* tp_free */ - (inquiry)0 /* tp_is_gc */ -}; +PYGLIB_DEFINE_TYPE("testhelper.FloatingWithSinkFunc", PyTestFloatingWithSinkFunc_Type, PyGObject); /* TestFloatingWithoutSinkFunc */ - -PyTypeObject PyTestFloatingWithoutSinkFunc_Type = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "testhelper.FloatingWithoutSinkFunc", /* tp_name */ - sizeof(PyGObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)0, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - (PyNumberMethods*)0, /* tp_as_number */ - (PySequenceMethods*)0, /* tp_as_sequence */ - (PyMappingMethods*)0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc)0, /* tp_getattro */ - (setattrofunc)0, /* tp_setattro */ - (PyBufferProcs*)0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* Documentation string */ - (traverseproc)0, /* tp_traverse */ - (inquiry)0, /* tp_clear */ - (richcmpfunc)0, /* tp_richcompare */ - offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - (struct PyMethodDef*)0, /* tp_methods */ - (struct PyMemberDef*)0, /* tp_members */ - (struct PyGetSetDef*)0, /* tp_getset */ - NULL, /* tp_base */ - NULL, /* tp_dict */ - (descrgetfunc)0, /* tp_descr_get */ - (descrsetfunc)0, /* tp_descr_set */ - offsetof(PyGObject, inst_dict), /* tp_dictoffset */ - (initproc)0, /* tp_init */ - (allocfunc)0, /* tp_alloc */ - (newfunc)0, /* tp_new */ - (freefunc)0, /* tp_free */ - (inquiry)0 /* tp_is_gc */ -}; +PYGLIB_DEFINE_TYPE("testhelper.FloatingWithoutSinkFunc", PyTestFloatingWithoutSinkFunc_Type, PyGObject); #include #include @@ -447,7 +271,7 @@ test4_callback (GObject *object, g_return_if_fail (b == TRUE); g_return_if_fail (l == 10L); g_return_if_fail (f <= 3.14001 && f >= 3.13999); - g_return_if_fail (d == 1.78); + g_return_if_fail (d <= 1.78001 && d >= 1.77999); g_return_if_fail (uint == 20); g_return_if_fail (ulong == 30L); } @@ -619,20 +443,17 @@ static PyMethodDef testhelper_functions[] = { { NULL, NULL } }; -void -inittesthelper () +PYGLIB_MODULE_START(testhelper, "testhelper") { PyObject *m, *d; - PyObject *module; g_thread_init(NULL); init_pygobject(); - m = Py_InitModule ("testhelper", testhelper_functions); - d = PyModule_GetDict(m); + d = PyModule_GetDict(module); - if ((module = PyImport_ImportModule("gobject")) != NULL) { - PyObject *moddict = PyModule_GetDict(module); + if ((m = PyImport_ImportModule("gobject")) != NULL) { + PyObject *moddict = PyModule_GetDict(m); _PyGObject_Type = (PyTypeObject *)PyDict_GetItemString(moddict, "GObject"); if (_PyGObject_Type == NULL) { @@ -647,33 +468,45 @@ inittesthelper () } /* TestInterface */ + PyTestInterface_Type.tp_methods = (struct PyMethodDef*)_PyTestInterface_methods; + PyTestInterface_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); pyg_register_interface(d, "Interface", TEST_TYPE_INTERFACE, &PyTestInterface_Type); pyg_register_interface_info(TEST_TYPE_INTERFACE, &__TestInterface__iinfo); /* TestUnknown */ + PyTestUnknown_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + PyTestUnknown_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist); + PyTestUnknown_Type.tp_dictoffset = offsetof(PyGObject, inst_dict); pygobject_register_class(d, "Unknown", TEST_TYPE_UNKNOWN, &PyTestUnknown_Type, Py_BuildValue("(O)", - &PyGObject_Type, - &PyTestInterface_Type)); + &PyGObject_Type, + &PyTestInterface_Type)); pyg_set_object_has_new_constructor(TEST_TYPE_UNKNOWN); //pyg_register_class_init(TEST_TYPE_UNKNOWN, __GtkUIManager_class_init); /* TestFloatingWithSinkFunc */ + PyTestFloatingWithSinkFunc_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + PyTestFloatingWithSinkFunc_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist); + PyTestFloatingWithSinkFunc_Type.tp_dictoffset = offsetof(PyGObject, inst_dict); pygobject_register_class(d, "FloatingWithSinkFunc", TEST_TYPE_FLOATING_WITH_SINK_FUNC, &PyTestFloatingWithSinkFunc_Type, Py_BuildValue("(O)", - &PyGObject_Type)); + &PyGObject_Type)); pyg_set_object_has_new_constructor(TEST_TYPE_FLOATING_WITH_SINK_FUNC); pygobject_register_sinkfunc(TEST_TYPE_FLOATING_WITH_SINK_FUNC, sink_test_floating_with_sink_func); /* TestFloatingWithoutSinkFunc */ + PyTestFloatingWithoutSinkFunc_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + PyTestFloatingWithoutSinkFunc_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist); + PyTestFloatingWithoutSinkFunc_Type.tp_dictoffset = offsetof(PyGObject, inst_dict); pygobject_register_class(d, "FloatingWithoutSinkFunc", TEST_TYPE_FLOATING_WITHOUT_SINK_FUNC, &PyTestFloatingWithoutSinkFunc_Type, Py_BuildValue("(O)", - &PyGObject_Type)); + &PyGObject_Type)); pyg_set_object_has_new_constructor(TEST_TYPE_FLOATING_WITHOUT_SINK_FUNC); } +PYGLIB_MODULE_END