def translate_enumeration(enum, constructor):
name = enum["name"]
name = rename_enumeration(name)
print "{0} = {1}({0!r}, {{".format(name, constructor)
# turns out the "expand" was insufficient nearly everywhere.
prefix = "^VK_"
for cell in split_case(name):
prefix += "(" + cell.upper() + "_)?"
for tag in enum:
if tag.name == "enum":
name_ = re.subn(prefix, "", tag["name"])[0]
if "bitpos" in tag.attrs:
value = "1 << " + tag["bitpos"]
else:
value = tag["value"]
print " {!r:<50}: {!s},".format(name_, value)
print "})"
return name
评论列表
文章目录