Generate type.
(self, typeinfo, name, alias)
| 325 | self.feature_not_empty = True |
| 326 | |
| 327 | def genType(self, typeinfo, name, alias): |
| 328 | "Generate type." |
| 329 | OutputGenerator.genType(self, typeinfo, name, alias) |
| 330 | typeElem = typeinfo.elem |
| 331 | |
| 332 | # Vulkan: |
| 333 | # Determine the category of the type, and the type section to add |
| 334 | # its definition to. |
| 335 | # 'funcpointer' is added to the 'struct' section as a workaround for |
| 336 | # internal issue #877, since structures and function pointer types |
| 337 | # can have cross-dependencies. |
| 338 | category = typeElem.get('category') |
| 339 | if category == 'funcpointer': |
| 340 | section = 'struct' |
| 341 | else: |
| 342 | section = category |
| 343 | |
| 344 | if category in ('struct', 'union'): |
| 345 | # If the type is a struct type, generate it using the |
| 346 | # special-purpose generator. |
| 347 | self.genStruct(typeinfo, name, alias) |
| 348 | else: |
| 349 | if self.genOpts is None: |
| 350 | raise MissingGeneratorOptionsError() |
| 351 | |
| 352 | body = self.deprecationComment(typeElem) |
| 353 | |
| 354 | # OpenXR: this section was not under 'else:' previously, just fell through |
| 355 | if alias: |
| 356 | # If the type is an alias, just emit a typedef declaration |
| 357 | body += f"typedef {alias} {name};\n" |
| 358 | elif category == 'funcpointer': |
| 359 | # Only include the typedef |
| 360 | decls = self.makeCDecls(typeElem) |
| 361 | body += decls[1] |
| 362 | else: |
| 363 | # Replace <apientry /> tags with an APIENTRY-style string |
| 364 | # (from self.genOpts). Copy other text through unchanged. |
| 365 | # If the resulting text is an empty string, do not emit it. |
| 366 | body += noneStr(typeElem.text) |
| 367 | for elem in typeElem: |
| 368 | if elem.tag == 'apientry': |
| 369 | body += self.genOpts.apientry + noneStr(elem.tail) |
| 370 | else: |
| 371 | body += noneStr(elem.text) + noneStr(elem.tail) |
| 372 | if category == 'define' and self.misracppstyle(): |
| 373 | body = body.replace("(uint32_t)", "static_cast<uint32_t>") |
| 374 | if body: |
| 375 | # Add extra newline after multi-line entries. |
| 376 | if '\n' in body[0:-1]: |
| 377 | body += '\n' |
| 378 | self.appendSection(section, body) |
| 379 | |
| 380 | def genProtectString(self, protect_str): |
| 381 | """Generate protection string. |
nothing calls this directly
no test coverage detected