MCPcopy Create free account
hub / github.com/enthought/comtypes / parse_typeinfo

Method parse_typeinfo

comtypes/tools/tlbparser.py:600–641  ·  view source on GitHub ↗
(self, tinfo: typeinfo.ITypeInfo)

Source from the content-addressed store, hash-verified

598 self.items[fullname] = value
599
600 def parse_typeinfo(self, tinfo: typeinfo.ITypeInfo) -> Any:
601 name = tinfo.GetDocumentation(-1)[0]
602 modname = self._typelib_module()
603 try:
604 return self.items[f"{modname}.{name}"]
605 except KeyError:
606 pass
607
608 tlib = tinfo.GetContainingTypeLib()[0]
609 if tlib != self.tlib:
610 return self._parse_External(name, tlib, tinfo)
611
612 ta = tinfo.GetTypeAttr()
613 tkind = ta.typekind
614
615 if tkind == typeinfo.TKIND_ENUM: # 0
616 return self.ParseEnum(tinfo, ta)
617 elif tkind == typeinfo.TKIND_RECORD: # 1
618 return self.ParseRecord(tinfo, ta)
619 elif tkind == typeinfo.TKIND_MODULE: # 2
620 return self.ParseModule(tinfo, ta)
621 elif tkind == typeinfo.TKIND_INTERFACE: # 3
622 return self.ParseInterface(tinfo, ta)
623 elif tkind == typeinfo.TKIND_DISPATCH: # 4
624 try:
625 # GetRefTypeOfImplType(-1) returns the custom portion
626 # of a dispinterface, if it is dual
627 # See https://learn.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-itypeinfo-getreftypeofimpltype#remarks
628 href = tinfo.GetRefTypeOfImplType(-1)
629 except COMError:
630 # no dual interface
631 return self.ParseDispatch(tinfo, ta)
632 return self._parse_DualInterface(tinfo.GetRefTypeInfo(href))
633 elif tkind == typeinfo.TKIND_COCLASS: # 5
634 return self.ParseCoClass(tinfo, ta)
635 elif tkind == typeinfo.TKIND_ALIAS: # 6
636 return self.ParseAlias(tinfo, ta)
637 elif tkind == typeinfo.TKIND_UNION: # 7
638 return self.ParseUnion(tinfo, ta)
639 else:
640 print("NYI", tkind)
641 # raise "NYI", tkind
642
643 def _parse_DualInterface(
644 self, tinfo: typeinfo.ITypeInfo

Callers 5

make_typeMethod · 0.95
ParseInterfaceMethod · 0.95
ParseDispatchMethod · 0.95
ParseCoClassMethod · 0.95
parseMethod · 0.95

Calls 15

_typelib_moduleMethod · 0.95
_parse_ExternalMethod · 0.95
ParseEnumMethod · 0.95
ParseRecordMethod · 0.95
ParseModuleMethod · 0.95
ParseInterfaceMethod · 0.95
ParseDispatchMethod · 0.95
_parse_DualInterfaceMethod · 0.95
ParseCoClassMethod · 0.95
ParseAliasMethod · 0.95
ParseUnionMethod · 0.95
GetContainingTypeLibMethod · 0.80

Tested by

no test coverage detected