Generate group (e.g. C "enum" type). These are concatenated together with other types. - Add the enum type name to the 'enums' dictionary, with the value being an ordered list of the enumerant names. - Add each enumerant name to the 'consts' dictionary, with
(self, groupinfo, groupName, alias)
| 312 | self.addMapping(typeName, member_type) |
| 313 | |
| 314 | def genGroup(self, groupinfo, groupName, alias): |
| 315 | """Generate group (e.g. C "enum" type). |
| 316 | |
| 317 | These are concatenated together with other types. |
| 318 | |
| 319 | - Add the enum type name to the 'enums' dictionary, with |
| 320 | the value being an ordered list of the enumerant names. |
| 321 | - Add each enumerant name to the 'consts' dictionary, with |
| 322 | the value being the enum type the enumerant is part of.""" |
| 323 | OutputGenerator.genGroup(self, groupinfo, groupName, alias) |
| 324 | groupElem = groupinfo.elem |
| 325 | |
| 326 | # Add a typeCategory{} entry for the category of this type. |
| 327 | self.addName(self.typeCategory, groupName, 'group') |
| 328 | |
| 329 | if alias: |
| 330 | # Add name -> alias mapping |
| 331 | self.addName(self.alias, groupName, alias) |
| 332 | else: |
| 333 | # May want to only emit definition on this branch |
| 334 | True |
| 335 | |
| 336 | # Add each nested 'enum' tag |
| 337 | enumerants = [elem.get('name') for elem in groupElem.findall('enum')] |
| 338 | for name in enumerants: |
| 339 | self.addName(self.consts, name, groupName) |
| 340 | |
| 341 | # Sort enums for output stability, since their order is irrelevant |
| 342 | self.enums[groupName] = sorted(enumerants) |
| 343 | |
| 344 | def genEnum(self, enuminfo, name, alias): |
| 345 | """Generate enumerant (compile time constant). |