def translate_enumeration(types, enum, constructor):
name = enum["name"]
name = rename_enumeration(name)
types[name] = this = {"type":constructor, "ctype":"i32"}
this["constants"] = constants = {}
# 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 << int(tag["bitpos"])
elif tag["value"].startswith("0x"):
value = int(tag["value"], 16)
else:
value = int(tag["value"])
constants[name_] = value
return name
评论列表
文章目录