def genNullDriverImpl():
    specialFuncNames = ['vkCreateGraphicsPipelines', 'vkCreateComputePipelines', 'vkGetInstanceProcAddr', 'vkGetDeviceProcAddr', 'vkEnumeratePhysicalDevices', 'vkEnumerateInstanceExtensionProperties', 'vkEnumerateDeviceExtensionProperties', 'vkGetPhysicalDeviceFeatures', 'vkGetPhysicalDeviceFeatures2KHR', 'vkGetPhysicalDeviceProperties', 'vkGetPhysicalDeviceProperties2KHR', 'vkGetPhysicalDeviceQueueFamilyProperties', 'vkGetPhysicalDeviceMemoryProperties', 'vkGetPhysicalDeviceFormatProperties', 'vkGetPhysicalDeviceImageFormatProperties', 'vkGetDeviceQueue', 'vkGetBufferMemoryRequirements', 'vkGetBufferMemoryRequirements2KHR', 'vkGetImageMemoryRequirements', 'vkGetImageMemoryRequirements2KHR', 'vkAllocateMemory', 'vkMapMemory', 'vkUnmapMemory', 'vkAllocateDescriptorSets', 'vkFreeDescriptorSets', 'vkResetDescriptorPool', 'vkAllocateCommandBuffers', 'vkFreeCommandBuffers', 'vkCreateDisplayModeKHR', 'vkCreateSharedSwapchainsKHR', 'vkGetPhysicalDeviceExternalBufferPropertiesKHR', 'vkGetPhysicalDeviceImageFormatProperties2KHR', 'vkGetMemoryAndroidHardwareBufferANDROID']
    coreFunctions = [f for f in api.functions if (not f.isAlias)]
    specialFuncs = [f for f in coreFunctions if (f.name in specialFuncNames)]
    createFuncs = [f for f in coreFunctions if (((f.name[:8] == 'vkCreate') or (f.name == 'vkAllocateMemory')) and (not (f in specialFuncs)))]
    destroyFuncs = [f for f in coreFunctions if (((f.name[:9] == 'vkDestroy') or (f.name == 'vkFreeMemory')) and (not (f in specialFuncs)))]
    dummyFuncs = [f for f in coreFunctions if (f not in ((specialFuncs + createFuncs) + destroyFuncs))]

    def getHandle(name):
        for handle in api.handles:
            if (handle.name == name[0]):
                return handle
        raise Exception(('No such handle: %s' % name))
    for function in createFuncs:
        objectType = function.arguments[(- 1)].type[:(- 1)]
        argsStr = ', '.join([a.name for a in function.arguments[:(- 1)]])
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        (yield ('\tDE_UNREF(%s);' % function.arguments[(- 2)].name))
        if (getHandle(objectType).type == Handle.TYPE_NONDISP):
            (yield ('\tVK_NULL_RETURN((*%s = allocateNonDispHandle<%s, %s>(%s)));' % (function.arguments[(- 1)].name, objectType[0][2:], objectType[0], argsStr)))
        else:
            (yield ('\tVK_NULL_RETURN((*%s = allocateHandle<%s, %s>(%s)));' % (function.arguments[(- 1)].name, objectType[0][2:], objectType[0], argsStr)))
        (yield '}')
        (yield '')
    for function in destroyFuncs:
        objectArg = function.arguments[(- 2)]
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        for arg in function.arguments[:(- 2)]:
            (yield ('\tDE_UNREF(%s);' % arg.name))
        if (getHandle(objectArg.type).type == Handle.TYPE_NONDISP):
            (yield ('\tfreeNonDispHandle<%s, %s>(%s, %s);' % (objectArg.getType()[2:], objectArg.getType(), objectArg.name, function.arguments[(- 1)].name)))
        else:
            (yield ('\tfreeHandle<%s, %s>(%s, %s);' % (objectArg.getType()[2:], objectArg.getType(), objectArg.name, function.arguments[(- 1)].name)))
        (yield '}')
        (yield '')
    for function in dummyFuncs:
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        for arg in function.arguments:
            (yield ('\tDE_UNREF(%s);' % arg.name))
        if (function.returnType != 'void'):
            (yield '\treturn VK_SUCCESS;')
        (yield '}')
        (yield '')

    def genFuncEntryTable(type, name):
        funcs = [f for f in api.functions if (f.getType() == type)]
        refFuncs = {}
        for f in api.functions:
            if (f.alias != None):
                refFuncs[f.alias] = f
        (yield ('static const tcu::StaticFunctionLibrary::Entry %s[] =' % name))
        (yield '{')
        for line in indentLines([('\tVK_NULL_FUNC_ENTRY(%s,\t%s),' % (function.name, getInterfaceName((function if (not function.isAlias) else refFuncs[function])))) for function in funcs]):
            (yield line)
        (yield '};')
        (yield '')
    for line in genFuncEntryTable(Function.TYPE_PLATFORM, 's_platformFunctions'):
        (yield line)
    for line in genFuncEntryTable(Function.TYPE_INSTANCE, 's_instanceFunctions'):
        (yield line)
    for line in genFuncEntryTable(Function.TYPE_DEVICE, 's_deviceFunctions'):
        (yield line)
def genNullDriverImpl():
    specialFuncNames = ['vkCreateGraphicsPipelines', 'vkCreateComputePipelines', 'vkGetInstanceProcAddr', 'vkGetDeviceProcAddr', 'vkEnumeratePhysicalDevices', 'vkEnumerateInstanceExtensionProperties', 'vkEnumerateDeviceExtensionProperties', 'vkGetPhysicalDeviceFeatures', 'vkGetPhysicalDeviceFeatures2KHR', 'vkGetPhysicalDeviceProperties', 'vkGetPhysicalDeviceProperties2KHR', 'vkGetPhysicalDeviceQueueFamilyProperties', 'vkGetPhysicalDeviceMemoryProperties', 'vkGetPhysicalDeviceFormatProperties', 'vkGetPhysicalDeviceImageFormatProperties', 'vkGetDeviceQueue', 'vkGetBufferMemoryRequirements', 'vkGetBufferMemoryRequirements2KHR', 'vkGetImageMemoryRequirements', 'vkGetImageMemoryRequirements2KHR', 'vkAllocateMemory', 'vkMapMemory', 'vkUnmapMemory', 'vkAllocateDescriptorSets', 'vkFreeDescriptorSets', 'vkResetDescriptorPool', 'vkAllocateCommandBuffers', 'vkFreeCommandBuffers', 'vkCreateDisplayModeKHR', 'vkCreateSharedSwapchainsKHR', 'vkGetPhysicalDeviceExternalBufferPropertiesKHR', 'vkGetPhysicalDeviceImageFormatProperties2KHR', 'vkGetMemoryAndroidHardwareBufferANDROID']
    coreFunctions = [f for f in api.functions if (not f.isAlias)]
    specialFuncs = [f for f in coreFunctions if (f.name in specialFuncNames)]
    createFuncs = [f for f in coreFunctions if (((f.name[:8] == 'vkCreate') or (f.name == 'vkAllocateMemory')) and (not (f in specialFuncs)))]
    destroyFuncs = [f for f in coreFunctions if (((f.name[:9] == 'vkDestroy') or (f.name == 'vkFreeMemory')) and (not (f in specialFuncs)))]
    dummyFuncs = [f for f in coreFunctions if (f not in ((specialFuncs + createFuncs) + destroyFuncs))]

    def getHandle(name):
        for handle in api.handles:
            if (handle.name == name[0]):
                return handle
        raise Exception(('No such handle: %s' % name))
    for function in createFuncs:
        objectType = function.arguments[(- 1)].type[:(- 1)]
        argsStr = ', '.join([a.name for a in function.arguments[:(- 1)]])
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        (yield ('\tDE_UNREF(%s);' % function.arguments[(- 2)].name))
        if (getHandle(objectType).type == Handle.TYPE_NONDISP):
            (yield ('\tVK_NULL_RETURN((*%s = allocateNonDispHandle<%s, %s>(%s)));' % (function.arguments[(- 1)].name, objectType[0][2:], objectType[0], argsStr)))
        else:
            (yield ('\tVK_NULL_RETURN((*%s = allocateHandle<%s, %s>(%s)));' % (function.arguments[(- 1)].name, objectType[0][2:], objectType[0], argsStr)))
        (yield '}')
        (yield )
    for function in destroyFuncs:
        objectArg = function.arguments[(- 2)]
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        for arg in function.arguments[:(- 2)]:
            (yield ('\tDE_UNREF(%s);' % arg.name))
        if (getHandle(objectArg.type).type == Handle.TYPE_NONDISP):
            (yield ('\tfreeNonDispHandle<%s, %s>(%s, %s);' % (objectArg.getType()[2:], objectArg.getType(), objectArg.name, function.arguments[(- 1)].name)))
        else:
            (yield ('\tfreeHandle<%s, %s>(%s, %s);' % (objectArg.getType()[2:], objectArg.getType(), objectArg.name, function.arguments[(- 1)].name)))
        (yield '}')
        (yield )
    for function in dummyFuncs:
        (yield ('VKAPI_ATTR %s VKAPI_CALL %s (%s)' % (function.returnType, getInterfaceName(function), argListToStr(function.arguments))))
        (yield '{')
        for arg in function.arguments:
            (yield ('\tDE_UNREF(%s);' % arg.name))
        if (function.returnType != 'void'):
            (yield '\treturn VK_SUCCESS;')
        (yield '}')
        (yield )

    def genFuncEntryTable(type, name):
        funcs = [f for f in api.functions if (f.getType() == type)]
        refFuncs = {}
        for f in api.functions:
            if (f.alias != None):
                refFuncs[f.alias] = f
        (yield ('static const tcu::StaticFunctionLibrary::Entry %s[] =' % name))
        (yield '{')
        for line in indentLines([('\tVK_NULL_FUNC_ENTRY(%s,\t%s),' % (function.name, getInterfaceName((function if (not function.isAlias) else refFuncs[function])))) for function in funcs]):
            (yield line)
        (yield '};')
        (yield )
    for line in genFuncEntryTable(Function.TYPE_PLATFORM, 's_platformFunctions'):
        (yield line)
    for line in genFuncEntryTable(Function.TYPE_INSTANCE, 's_instanceFunctions'):
        (yield line)
    for line in genFuncEntryTable(Function.TYPE_DEVICE, 's_deviceFunctions'):
        (yield line)