diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-10-15 03:57:52 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-09 20:44:33 -0800 |
commit | 415b240e3baab522f3bf9752995610f950ba609e (patch) | |
tree | 01802aff84fae0ebdd0c4574280247ff415e3d34 | |
parent | 9b02b29016958791dfa9d7ebfc6c2ec44ab5690d (diff) | |
download | pygobject-415b240e3baab522f3bf9752995610f950ba609e.tar.gz |
Remove special case GObject base class check when creating GI classes
Replace explicit GObject.Object string name check when calculating the
introspection class hierarchy with a more generalized technique. This allows
any C based wrapper of a GType to "underride" an introspection class
automatically. This currently only handles the case of GObject.Object, but
will be used for fundamentals and GParamSpec.
https://bugzilla.gnome.org/show_bug.cgi?id=631901
-rw-r--r-- | gi/module.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gi/module.py b/gi/module.py index ae6f6e2d..89969267 100644 --- a/gi/module.py +++ b/gi/module.py @@ -60,8 +60,7 @@ from .types import \ StructMeta from ._gobject._gobject import \ - GInterface, \ - GObject + GInterface from ._gobject.constants import \ TYPE_NONE, \ @@ -81,10 +80,16 @@ def get_parent_for_object(object_info): parent_object_info = object_info.get_parent() if not parent_object_info: - # Special case GObject.Object as being derived from the static GObject. - if object_info.get_namespace() == 'GObject' and object_info.get_name() == 'Object': - return GObject - + # If we reach the end of the introspection info class hierarchy, look + # for an existing wrapper on the GType and use it as a base for the + # new introspection wrapper. This allows static C wrappers already + # registered with the GType to be used as the introspection base + # (_gobject.GObject for example) + gtype = object_info.get_g_type() + if gtype and gtype.pytype: + return gtype.pytype + + # Otherwise use builtins.object as the base return object namespace = parent_object_info.get_namespace() |