Generate tables of enumerant values and short descriptions from the XML.
(self, groupinfo, groupName)
| 494 | self.writeInclude('structs', typeName, body, deprecatedby, deprecatedlink, supersededby) |
| 495 | |
| 496 | def genEnumTable(self, groupinfo, groupName): |
| 497 | """Generate tables of enumerant values and short descriptions from |
| 498 | the XML.""" |
| 499 | |
| 500 | values = [] |
| 501 | got_comment = False |
| 502 | missing_comments = [] |
| 503 | for elem in groupinfo.elem.findall('enum'): |
| 504 | if not elem.get('required'): |
| 505 | continue |
| 506 | name = elem.get('name') |
| 507 | |
| 508 | data = { |
| 509 | 'name': name, |
| 510 | } |
| 511 | |
| 512 | (numVal, _) = self.enumToValue(elem, True) |
| 513 | data['value'] = numVal |
| 514 | |
| 515 | extname = elem.get('extname') |
| 516 | |
| 517 | added_by_extension_to_core = (extname is not None and self.in_core) |
| 518 | if added_by_extension_to_core and not self.genOpts.extEnumerantAdditions: |
| 519 | # We are skipping such values |
| 520 | continue |
| 521 | |
| 522 | comment = elem.get('comment') |
| 523 | if comment: |
| 524 | got_comment = True |
| 525 | elif name.endswith('_UNKNOWN') and numVal == 0: |
| 526 | # This is a placeholder for 0-initialization to be clearly invalid. |
| 527 | # Just skip this silently |
| 528 | continue |
| 529 | else: |
| 530 | # Skip but record this in case it is an odd-one-out missing |
| 531 | # a comment. |
| 532 | missing_comments.append(name) |
| 533 | continue |
| 534 | |
| 535 | if added_by_extension_to_core and self.genOpts.extEnumerantFormatString: |
| 536 | # Add a note to the comment |
| 537 | comment += self.genOpts.extEnumerantFormatString.format( |
| 538 | self.conventions.formatExtension(extname)) |
| 539 | |
| 540 | data['comment'] = comment |
| 541 | values.append(data) |
| 542 | |
| 543 | if got_comment: |
| 544 | # If any had a comment, output it. |
| 545 | |
| 546 | if missing_comments: |
| 547 | self.logMsg('warn', 'The following values for', groupName, |
| 548 | 'were omitted from the table due to missing comment attributes:', |
| 549 | ', '.join(missing_comments)) |
| 550 | |
| 551 | group_type = groupinfo.elem.get('type') |
| 552 | if groupName == self.result_type: |
| 553 | # Split this into success and failure |
no test coverage detected