INNER CODE UNIT · Python

parse_xml_enums

mosra/flextgl · flext.py:341

def parse_xml_enums(root, api):
    enums = {}

    for enum in root.findall("./enums/enum"):
        # Doesn't seem to be used in Vulkan, so no need to handle cases like
        # `api="vulkan,vulkansc,vulkanbase"` here.
        if ('api' in enum.attrib and enum.attrib['api'] != api): continue
        name  = enum.attrib['name']
        # GL type attribute is a literal suffix (which we need), while Vulkan
        # type attribute (since 1.2.174) is an actual C type, which we don't
        # need.
        if 'type' in enum.attrib and api != 'vulkan':
            value = "%s%s" % (enum.attrib['value'], enum.attrib['type'])
        # Note that this case doesn't need special handling for Vulkan 64-bit
        # enums, as the values parsed here are never used. The other cases
        # with << have appropriate handling.
        elif 'bitpos' in enum.attrib:
            value = "1 << {}".format(enum.attrib['bitpos'])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…