(
self, tinfo: typeinfo.ITypeInfo, ta: typeinfo.TYPEATTR
)
| 543 | |
| 544 | # TKIND_UNION = 7 |
| 545 | def ParseUnion( |
| 546 | self, tinfo: typeinfo.ITypeInfo, ta: typeinfo.TYPEATTR |
| 547 | ) -> typedesc.Union: |
| 548 | union_name, doc, helpcntext, helpfile = tinfo.GetDocumentation(-1) |
| 549 | members = [] |
| 550 | union = typedesc.Union( |
| 551 | union_name, |
| 552 | align=ta.cbAlignment * 8, |
| 553 | members=members, |
| 554 | bases=[], |
| 555 | size=ta.cbSizeInstance * 8, |
| 556 | ) |
| 557 | self._register(union_name, union) |
| 558 | |
| 559 | tlib, _ = tinfo.GetContainingTypeLib() |
| 560 | tlib_ta = tlib.GetLibAttr() |
| 561 | # If this is a 32-bit typlib being loaded in a 64-bit process, then the |
| 562 | # size and alignment are incorrect. Set the size to None to disable |
| 563 | # size checks and correct the alignment. |
| 564 | if is_64bits and tlib_ta.syskind == typeinfo.SYS_WIN32: |
| 565 | union.size = None |
| 566 | union.align = 64 |
| 567 | |
| 568 | for i in range(ta.cVars): |
| 569 | vd = tinfo.GetVarDesc(i) |
| 570 | name = tinfo.GetDocumentation(vd.memid)[0] |
| 571 | offset = vd._.oInst * 8 |
| 572 | assert vd.varkind == typeinfo.VAR_PERINSTANCE |
| 573 | typ = self.make_type(vd.elemdescVar.tdesc, tinfo) |
| 574 | field = typedesc.Field(name, typ, None, offset) # bits |
| 575 | members.append(field) |
| 576 | return union |
| 577 | |
| 578 | ################################################################ |
| 579 |
no test coverage detected