

def Bind(self, name, flags=0, lHashVal=0):
    'Bind to a name'
    bindptr = BINDPTR()
    desckind = DESCKIND()
    ti = POINTER(ITypeInfo)()
    self.__com_Bind(name, lHashVal, flags, byref(ti), byref(desckind), byref(bindptr))
    kind = desckind.value
    if (kind == DESCKIND_FUNCDESC):
        fd = bindptr.lpfuncdesc[0]
        fd.__ref__ = weakref.ref(fd, (lambda dead: ti.ReleaseFuncDesc(bindptr.lpfuncdesc)))
        return ('function', fd)
    elif (kind == DESCKIND_VARDESC):
        vd = bindptr.lpvardesc[0]
        vd.__ref__ = weakref.ref(vd, (lambda dead: ti.ReleaseVarDesc(bindptr.lpvardesc)))
        return ('variable', vd)
    elif (kind == DESCKIND_TYPECOMP):
        return ('type', bindptr.lptcomp)
    elif (kind == DESCKIND_IMPLICITAPPOBJ):
        raise NotImplementedError
    elif (kind == DESCKIND_NONE):
        raise NameError(('Name %s not found' % name))

dataset/ETHPy150Open enthought/comtypes/comtypes/typeinfo.py ITypeComp.Bind/original