##
 #######################################################################################################################
 #
 #  Copyright (c) 2017-2018 Advanced Micro Devices, Inc. All Rights Reserved.
 #
 #  Permission is hereby granted, free of charge, to any person obtaining a copy
 #  of this software and associated documentation files (the "Software"), to deal
 #  in the Software without restriction, including without limitation the rights
 #  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 #  copies of the Software, and to permit persons to whom the Software is
 #  furnished to do so, subject to the following conditions:
 #
 #  The above copyright notice and this permission notice shall be included in all
 #  copies or substantial portions of the Software.
 #
 #  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 #  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 #  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 #  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 #  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 #  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 #  SOFTWARE.
 #
 #######################################################################################################################

import os
CopyrightFilePath = os.path.dirname(os.path.realpath(__file__)) + "/../xgl-copyright-template.txt"
FileHeaderCopyright = open(CopyrightFilePath, 'r').read()

FileHeaderWarning = "\
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\
//\n\
// WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!\n\
//\n\
// This code has been generated automatically. Do not hand-modify this code.\n\
//\n\
// When changes are needed, modify the tools generating this module in the tools\\generate directory OR settings.cfg\n\
//\n\
// WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING!  WARNING! WARNING!  WARNING!  WARNING!  WARNING!\n\
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\
\n"

CopyrightAndWarning = FileHeaderCopyright + FileHeaderWarning

HeaderFileDoxComment = "\n\
/**\n\
************************************************************************************************************************\n\
* @file  %FileName%.h\n\
* @brief auto-generated file.\n\
*        Contains the definition for the Vulkan settings struct and enums for initialization.\n\
************************************************************************************************************************\n\
*/\n\
#pragma once\n"

VkIncludes = "\n\
#include \"palInlineFuncs.h\"\n\
#include \"palDevice.h\"\n\n"

VkEnum = "\n\
enum %EnumName%\n\
{\n\
%EnumData%\n\
};\n"

StructDef = "\n\
struct %SettingStructName%\n\
{\n\
%SettingDefs%\
};\n"

SettingDef = "    %SettingType%    %SettingVarName%%CharArrayLength%;\n"

SettingStr = "static const char* %SettingStrName% = %SettingString%;\n"

SourceFileDoxComment = "\n\
/**\n\
************************************************************************************************************************\n\
* @file  %FileName%.cpp\n\
* @brief Autogenerated class.\n\
*        Contains the implementation for the auto-generated functions for loading settings.\n\
************************************************************************************************************************\n\
*/\n"

SetupDefaultsFunc = "\n\
// =====================================================================================================================\n\
// Initializes the settings structure to default values.\n\
void SetupDefaults(%SettingStructName%* pSettings)\n\
{\n\
    // set setting variables to their default values...\n\
%SetDefaultsCode%\n\
}\n"

SetDefault = "    pSettings->%SettingVarName% = %SettingDefault%;\n"
SetStringDefault = "    memset(pSettings->%SettingVarName%, 0, %SettingStringLength%);\n\
    strncpy(pSettings->%SettingVarName%, %SettingDefault%, %SettingStringLength%);\n"
SetOsStringDefault = "    memset(pSettings->%SettingVarName%, 0, %SettingStringLength%);\n\
#if defined(_WIN32)\n\
    strncpy(pSettings->%SettingVarName%, %SettingDefaultWin%, %SettingStringLength%);\n\
#elif (__unix__)\n\
    strncpy(pSettings->%SettingVarName%, %SettingDefaultLnx%, %SettingStringLength%);\n\
#endif\n"

ReadSettingsFunc = "\n\
// =====================================================================================================================\n\
// Reads the setting from the OS adapter and sets the structure value when the setting values are found.\n\
void ReadSettings(\n\
    const Pal::IDevice*  pDevice,\n\
    %SettingStructName%* pSettings)\n\
{\n\
    // read from the OS adapter for each individual setting\n\
%ReadSettingsCode%\n\
}\n"

VkReadSettingClass="pDevice"

ReadSetting = "    %ReadSettingClass%->ReadSetting(\n\
        %SettingStrName%,\n\
        Pal::SettingScope::Driver,\n\
        %SettingRegistryType%,\n\
        &pSettings->%SettingVarName%);\n\n"
ReadSettingStr = "    %ReadSettingClass%->ReadSetting(\n\
        %SettingStrName%,\n\
        Pal::SettingScope::Driver,\n\
        %SettingRegistryType%,\n\
        &pSettings->%SettingVarName%,\n\
        %StringLength%);\n\n"
