(
self, tinfo: typeinfo.ITypeInfo, ta: typeinfo.TYPEATTR
)
| 324 | |
| 325 | # TKIND_DISPATCH = 4 |
| 326 | def ParseDispatch( |
| 327 | self, tinfo: typeinfo.ITypeInfo, ta: typeinfo.TYPEATTR |
| 328 | ) -> typedesc.DispInterface: |
| 329 | itf_name, doc = tinfo.GetDocumentation(-1)[0:2] |
| 330 | assert ta.cImplTypes == 1 |
| 331 | hr = tinfo.GetRefTypeOfImplType(0) |
| 332 | tibase = tinfo.GetRefTypeInfo(hr) |
| 333 | base = self.parse_typeinfo(tibase) |
| 334 | iid = str(ta.guid) |
| 335 | idlflags = self.interface_type_flags(ta.wTypeFlags) |
| 336 | doc = str(doc.split("\0")[0]) if doc is not None else doc |
| 337 | itf = typedesc.DispInterface(itf_name, base, iid, idlflags, doc) |
| 338 | self._register(itf_name, itf) |
| 339 | |
| 340 | # This code can only handle pure dispinterfaces. Dual |
| 341 | # interfaces are parsed in ParseInterface(). |
| 342 | assert ta.wTypeFlags & typeinfo.TYPEFLAG_FDUAL == 0 |
| 343 | |
| 344 | for i in range(ta.cVars): |
| 345 | vd = tinfo.GetVarDesc(i) |
| 346 | assert vd.varkind == typeinfo.VAR_DISPATCH |
| 347 | var_name, var_doc = tinfo.GetDocumentation(vd.memid)[0:2] |
| 348 | typ = self.make_type(vd.elemdescVar.tdesc, tinfo) |
| 349 | mth = typedesc.DispProperty( |
| 350 | vd.memid, var_name, typ, self.var_flags(vd.wVarFlags), var_doc |
| 351 | ) |
| 352 | itf.add_member(mth) |
| 353 | |
| 354 | # At least the EXCEL typelib lists the IUnknown and IDispatch |
| 355 | # methods even for this kind of interface. I didn't find any |
| 356 | # indication about these methods in the various flags, so we |
| 357 | # have to exclude them by name. |
| 358 | # CLF: 12/14/2012 Do this in a way that does not exclude other methods. |
| 359 | # I have encountered typlibs where only "QueryInterface", "AddRef" |
| 360 | # and "Release" are to be skipped. |
| 361 | ignored_names = set( |
| 362 | [ |
| 363 | "QueryInterface", |
| 364 | "AddRef", |
| 365 | "Release", |
| 366 | "GetTypeInfoCount", |
| 367 | "GetTypeInfo", |
| 368 | "GetIDsOfNames", |
| 369 | "Invoke", |
| 370 | ] |
| 371 | ) |
| 372 | |
| 373 | for i in range(ta.cFuncs): |
| 374 | fd = tinfo.GetFuncDesc(i) |
| 375 | func_name, func_doc = tinfo.GetDocumentation(fd.memid)[:2] |
| 376 | if func_name in ignored_names: |
| 377 | continue |
| 378 | assert fd.funckind == typeinfo.FUNC_DISPATCH |
| 379 | |
| 380 | returns = self.make_type(fd.elemdescFunc.tdesc, tinfo) |
| 381 | names = tinfo.GetNames(fd.memid, fd.cParams + 1) |
| 382 | names.append("rhs") |
| 383 | names = names[: fd.cParams + 1] |
no test coverage detected