[pygobject] [gi] handle virtual invokers
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] [gi] handle virtual invokers
- Date: Wed, 10 Nov 2010 02:17:26 +0000 (UTC)
commit 87dbc716f26cefc0e9427c3d6e8befe8eabd3d1e
Author: John (J5) Palmieri <johnp redhat com>
Date: Tue Nov 9 21:12:54 2010 -0500
[gi] handle virtual invokers
* right now we check to see if there is an method with the same name
as the virtual method and assume that is the invoker
* some invokers are named different so we now ask the VFuncInfo if
the vfunc has an invoker
* this is still not completly correct, gi needs to support telling
us which vfuncs must be overridden.
* this keeps the old way of checking vfuncs while adding the edge case
where vfunc is named differently from their invoker
gi/pygi-info.c | 16 ++++++++++++++++
gi/types.py | 2 +-
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 683c08d..e0787c7 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -1325,7 +1325,23 @@ static PyMethodDef _PyGIUnresolvedInfo_methods[] = {
/* GIVFuncInfo */
PYGLIB_DEFINE_TYPE ("gi.VFuncInfo", PyGIVFuncInfo_Type, PyGIBaseInfo);
+static PyObject *
+_wrap_g_vfunc_info_get_invoker (PyGIBaseInfo *self)
+{
+ PyObject *result = Py_None;
+ GIBaseInfo *info;
+
+ info = (GIBaseInfo *) g_vfunc_info_get_invoker ( (GIVFuncInfo *) self->info );
+ if (info)
+ result = _pygi_info_new(info);
+ else
+ Py_INCREF(Py_None);
+
+ return result;
+}
+
static PyMethodDef _PyGIVFuncInfo_methods[] = {
+ { "get_invoker", (PyCFunction) _wrap_g_vfunc_info_get_invoker, METH_NOARGS },
{ NULL, NULL, 0 }
};
diff --git a/gi/types.py b/gi/types.py
index 687e5d5..18b4013 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -100,7 +100,7 @@ class MetaClassHelper(object):
for vfunc_info in base.__info__.get_vfuncs():
vfunc = getattr(cls, 'do_' + vfunc_info.get_name(), None)
if vfunc is None and isinstance(base.__info__, InterfaceInfo) and \
- not hasattr(cls, vfunc_info.get_name()):
+ (not hasattr(cls, vfunc_info.get_name()) and not vfunc_info.get_invoker()):
raise TypeError('Class implementing %s.%s should implement '
'the method do_%s()' % (base.__info__.get_namespace(),
base.__info__.get_name(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]