[pygobject/gsoc2009: 136/160] Add interface inheritance to objects
- From: Simon van der Linden <svdlinden src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject/gsoc2009: 136/160] Add interface inheritance to objects
- Date: Fri, 14 Aug 2009 21:35:10 +0000 (UTC)
commit 04f11c5e3b8414450a3099ef6142f447b44520ed
Author: Simon van der Linden <svdlinden src gnome org>
Date: Wed Aug 12 12:37:19 2009 +0200
Add interface inheritance to objects
gi/module.py | 16 ++++++++++++++--
gi/pygi-info.c | 1 +
gi/types.py | 9 +++------
3 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 943d14a..7824258 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -61,6 +61,16 @@ 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():
+ namespace = interface_info.get_namespace()
+ name = interface_info.get_name()
+
+ module = __import__('gi.repository.%s' % namespace, fromlist=[name])
+ interfaces.append(getattr(module, name))
+ return interfaces
+
class DynamicModule(object):
@@ -99,10 +109,12 @@ class DynamicModule(object):
# Create a wrapper.
if isinstance(info, ObjectInfo):
- bases = (get_parent_for_object(info),)
+ parent = get_parent_for_object(info)
+ interfaces = tuple(interface for interface in get_interfaces_for_object(info)
+ if not issubclass(parent, interface))
+ bases = (parent,) + interfaces
metaclass = GObjectMeta
elif isinstance(info, InterfaceInfo):
- # FIXME
bases = (GInterface,)
metaclass = GObjectMeta
elif isinstance(info, StructInfo):
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 972f95e..bc3a3c3 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -586,6 +586,7 @@ _wrap_g_function_info_invoke (PyGIBaseInfo *self,
in_args[0].v_pointer = pyg_boxed_get(py_arg, void);
break;
case GI_INFO_TYPE_OBJECT:
+ case GI_INFO_TYPE_INTERFACE:
in_args[0].v_pointer = pygobject_get(py_arg);
break;
default:
diff --git a/gi/types.py b/gi/types.py
index 2076e2e..c27119f 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -47,8 +47,6 @@ class MetaClassHelper(object):
def _setup_methods(cls):
constructor_infos = []
method_infos = cls.__info__.get_methods()
- if hasattr(cls.__info__, 'get_interfaces'):
- method_infos += reduce(lambda x, y: x + y, [interface_info.get_methods() for interface_info in cls.__info__.get_interfaces()], ())
for method_info in method_infos:
name = method_info.get_name()
@@ -94,13 +92,12 @@ class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
if cls.__name__ != cls.__info__.get_name():
return;
- if hasattr(cls, '__gtype__'):
- setObjectHasNewConstructor(cls.__gtype__)
-
cls._setup_methods()
- if isinstance(cls.__info__, ObjectInfo):
+ if (isinstance(cls.__info__, ObjectInfo)):
cls._setup_fields()
+ if hasattr(cls, '__gtype__'):
+ setObjectHasNewConstructor(cls.__gtype__)
class StructMeta(type, MetaClassHelper):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]