def parseAPI(src):
    definitions = [Definition(type, name, parsePreprocDefinedValue(src, name)) for (name, type) in DEFINITIONS]
    handles = parseHandles(src)
    rawEnums = parseEnums(src)
    bitfieldNames = parseBitfieldNames(src)
    enums = []
    bitfields = []
    bitfieldEnums = set([getBitEnumNameForBitfield(n) for n in bitfieldNames if (getBitEnumNameForBitfield(n) in [enum.name for enum in rawEnums])])
    compositeTypes = parseCompositeTypes(src)
    allFunctions = parseFunctionsByVersion(src)
    for enum in rawEnums:
        if (enum.name in bitfieldEnums):
            bitfields.append(Bitfield(getBitfieldNameForBitEnum(enum.name), enum.values))
        else:
            enums.append(enum)
    for bitfieldName in bitfieldNames:
        if (not (bitfieldName in [bitfield.name for bitfield in bitfields])):
            bitfields.append(Bitfield(bitfieldName, []))
    populateAliasesWithTypedefs(compositeTypes, src)
    populateAliasesWithTypedefs(enums, src)
    populateAliasesWithTypedefs(bitfields, src)
    populateAliases(allFunctions)
    populateAliases(handles)
    populateAliases(enums)
    populateAliases(bitfields)
    populateAliases(compositeTypes)
    for enum in enums:
        removeAliasedValues(enum)
    extensions = parseExtensions(src, allFunctions, compositeTypes, enums, bitfields, handles, definitions)
    return API(definitions=definitions, handles=handles, enums=enums, bitfields=bitfields, compositeTypes=compositeTypes, functions=allFunctions, extensions=extensions)
def parseAPI(src):
    definitions = [Definition(type, name, parsePreprocDefinedValue(src, name)) for (name, type) in DEFINITIONS]
    handles = parseHandles(src)
    rawEnums = parseEnums(src)
    bitfieldNames = parseBitfieldNames(src)
    enums = []
    bitfields = []
    bitfieldEnums = set([getBitEnumNameForBitfield(n) for n in bitfieldNames if (getBitEnumNameForBitfield(n) in [enum.name for enum in rawEnums])])
    compositeTypes = parseCompositeTypes(src)
    allFunctions = parseFunctionsByVersion(src)
    for enum in rawEnums:
        if (enum.name in bitfieldEnums):
            bitfields.append(Bitfield(getBitfieldNameForBitEnum(enum.name), enum.values))
        else:
            enums.append(enum)
    for bitfieldName in bitfieldNames:
        if (not (bitfieldName in [bitfield.name for bitfield in bitfields])):
            bitfields.append(Bitfield(bitfieldName, []))
    populateAliasesWithTypedefs(compositeTypes, src)
    populateAliasesWithTypedefs(enums, src)
    populateAliasesWithTypedefs(bitfields, src)
    populateAliases(allFunctions)
    populateAliases(handles)
    populateAliases(enums)
    populateAliases(bitfields)
    populateAliases(compositeTypes)
    for enum in enums:
        removeAliasedValues(enum)
    extensions = parseExtensions(src, allFunctions, compositeTypes, enums, bitfields, handles, definitions)
    return API(definitions=definitions, handles=handles, enums=enums, bitfields=bitfields, compositeTypes=compositeTypes, functions=allFunctions, extensions=extensions)