Generate struct (e.g. C "struct" type). This is a special case of the tag where the contents are interpreted as a set of tags instead of freeform C C type declarations. The tags are just like tags - they are a declaration of a struct
(self, typeinfo, typeName, alias)
| 443 | return typeName in self.may_alias |
| 444 | |
| 445 | def genStruct(self, typeinfo, typeName, alias): |
| 446 | """Generate struct (e.g. C "struct" type). |
| 447 | |
| 448 | This is a special case of the <type> tag where the contents are |
| 449 | interpreted as a set of <member> tags instead of freeform C |
| 450 | C type declarations. The <member> tags are just like <param> |
| 451 | tags - they are a declaration of a struct or union member. |
| 452 | Only simple member declarations are supported (no nested |
| 453 | structs etc.) |
| 454 | |
| 455 | If alias is not None, then this struct aliases another; just |
| 456 | generate a typedef of that alias.""" |
| 457 | OutputGenerator.genStruct(self, typeinfo, typeName, alias) |
| 458 | |
| 459 | if self.genOpts is None: |
| 460 | raise MissingGeneratorOptionsError() |
| 461 | |
| 462 | typeElem = typeinfo.elem |
| 463 | body = self.deprecationComment(typeElem) |
| 464 | |
| 465 | if alias: |
| 466 | body += f"typedef {alias} {typeName};\n" |
| 467 | else: |
| 468 | (protect_begin, protect_end) = self.genProtectString(typeElem.get('protect')) |
| 469 | if protect_begin: |
| 470 | body += protect_begin |
| 471 | |
| 472 | if self.genOpts.genStructExtendsComment: |
| 473 | structextends = typeElem.get('structextends') |
| 474 | body += f"// {typeName} extends {structextends}\n" if structextends else '' |
| 475 | |
| 476 | body += f"typedef {typeElem.get('category')}" |
| 477 | |
| 478 | # This is an OpenXR-specific alternative where aliasing refers |
| 479 | # to an inheritance hierarchy of types rather than C-level type |
| 480 | # aliases. |
| 481 | if self.genOpts.genAliasMacro and self.typeMayAlias(typeName): |
| 482 | body += f" {self.genOpts.aliasMacro}" |
| 483 | |
| 484 | body += f" {typeName} {{\n" |
| 485 | |
| 486 | targetLen = self.getMaxCParamTypeLength(typeinfo) |
| 487 | for member in typeElem.findall('.//member'): |
| 488 | body += self.deprecationComment(member, indent = 4) |
| 489 | body += self.makeCParamDecl(member, targetLen + 4) |
| 490 | body += ';\n' |
| 491 | body += f"}} {typeName};\n" |
| 492 | if protect_end: |
| 493 | body += protect_end |
| 494 | |
| 495 | self.appendSection('struct', body) |
| 496 | |
| 497 | def genGroup(self, groupinfo, groupName, alias=None): |
| 498 | """Generate groups (e.g. C "enum" type). |
no test coverage detected