[pygobject] Remove special case GObject base class check when creating GI classes
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Remove special case GObject base class check when creating GI classes
- Date: Fri, 10 Jan 2014 04:47:24 +0000 (UTC)
commit 415b240e3baab522f3bf9752995610f950ba609e
Author: Simon Feltman <sfeltman src gnome org>
Date: Tue Oct 15 03:57:52 2013 -0700
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
gi/module.py | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index ae6f6e2..8996926 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()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]