'Dispatch a call to an interface method.'

def dispatch(self, ob, index, argPtr, ReadFromInTuple=_univgw.ReadFromInTuple, WriteFromOutTuple=_univgw.WriteFromOutTuple):

    meth = self._methods[index]
    hr = 0
    args = ReadFromInTuple(meth._gw_in_args, argPtr)
    ob = getattr(ob, 'policy', ob)
    ob._dispid_to_func_[meth.dispid] = meth.name
    retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None)
    if (type(retVal) == tuple):
        if (len(retVal) == (len(meth._gw_out_args) + 1)):
            hr = retVal[0]
            retVal = retVal[1:]
        else:
            raise TypeError(('Expected    %s    return    values,    got:    %s' % ((len(meth._gw_out_args) + 1), len(retVal))))
    else:
        retVal = [retVal]
        retVal.extend(([None] * (len(meth._gw_out_args) - 1)))
        retVal = tuple(retVal)
    WriteFromOutTuple(retVal, meth._gw_out_args, argPtr)
    return hr
