vkstruct_json.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:vkstruct 作者: cheery 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号