Commit 87dbc716 authored by John (J5) Palmieri's avatar John (J5) Palmieri
Browse files

[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
parent 540e9f1f
......@@ -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 }
};
......
......@@ -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(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment