mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2025-09-10 12:28:48 -04:00
Add platform specific protection for enum classes listed in a platform-protected extension. (#310)
This commit is contained in:
parent
45590a9bd7
commit
fe614bd960
@ -1587,26 +1587,35 @@ void VulkanHppGenerator::readExtensionRequireType(tinyxml2::XMLElement const* el
|
|||||||
{
|
{
|
||||||
std::string name = attributes.find("name")->second;
|
std::string name = attributes.find("name")->second;
|
||||||
|
|
||||||
assert(m_handles.find(name) == m_handles.end());
|
|
||||||
std::string protect = m_platforms.find(platform)->second;
|
|
||||||
|
|
||||||
auto bmit = m_bitmasks.find(name);
|
auto bmit = m_bitmasks.find(name);
|
||||||
if (bmit != m_bitmasks.end())
|
if (bmit != m_bitmasks.end())
|
||||||
{
|
{
|
||||||
|
assert(bmit->second.platform.empty());
|
||||||
bmit->second.platform = platform;
|
bmit->second.platform = platform;
|
||||||
assert(m_bitmaskBits.find(bmit->second.requires) != m_bitmaskBits.end());
|
assert(m_bitmaskBits.find(bmit->second.requires) != m_bitmaskBits.end());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string strippedName = stripPrefix(name, "Vk");
|
auto eit = m_enums.find(name);
|
||||||
std::map<std::string, StructureData>::iterator stit = m_structures.find(name);
|
if (eit != m_enums.end())
|
||||||
|
{
|
||||||
|
assert(eit->second.platform.empty());
|
||||||
|
eit->second.platform = platform;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto stit = m_structures.find(name);
|
||||||
if (stit != m_structures.end())
|
if (stit != m_structures.end())
|
||||||
{
|
{
|
||||||
|
assert(stit->second.protect.empty());
|
||||||
|
assert(m_handles.find(name) == m_handles.end());
|
||||||
|
std::string protect = m_platforms.find(platform)->second;
|
||||||
stit->second.protect = protect;
|
stit->second.protect = protect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert((m_defines.find(strippedName) != m_defines.end()) || (m_enums.find(name) != m_enums.end()));
|
assert((m_defines.find(name) != m_defines.end()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2548,13 +2557,18 @@ void VulkanHppGenerator::writeEnum(std::ostream & os, std::pair<std::string,Enum
|
|||||||
values += "\n ";
|
values += "\n ";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::string enumTemplate = R"(
|
assert(m_platforms.find(enumData.second.platform) != m_platforms.end());
|
||||||
|
std::string const& protect = m_platforms.find(enumData.second.platform)->second;
|
||||||
|
|
||||||
|
static const std::string enumTemplate = R"(${enterProtect}
|
||||||
enum class ${name}
|
enum class ${name}
|
||||||
{${values}};
|
{${values}};
|
||||||
)";
|
${leaveProtect})";
|
||||||
|
|
||||||
os << replaceWithMap(enumTemplate,
|
os << replaceWithMap(enumTemplate,
|
||||||
{
|
{
|
||||||
|
{ "enterProtect", protect.empty() ? "" : ("\n#ifdef " + protect) },
|
||||||
|
{ "leaveProtect", protect.empty() ? "" : ("#endif /*" + protect + "*/\n") },
|
||||||
{ "name", stripPrefix(enumData.first, "Vk") },
|
{ "name", stripPrefix(enumData.first, "Vk") },
|
||||||
{ "values", values },
|
{ "values", values },
|
||||||
});
|
});
|
||||||
|
@ -106,8 +106,9 @@ class VulkanHppGenerator
|
|||||||
{
|
{
|
||||||
void addEnumValue(std::string const& valueName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag);
|
void addEnumValue(std::string const& valueName, bool bitmask, std::string const& prefix, std::string const& postfix, std::string const& tag);
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> values; // pairs of vulkan enum value and corresponding vk::-namespace enum value
|
|
||||||
std::vector<std::pair<std::string, std::string>> aliases; // pairs of vulkan enum value and corresponding vk::-namespace enum value
|
std::vector<std::pair<std::string, std::string>> aliases; // pairs of vulkan enum value and corresponding vk::-namespace enum value
|
||||||
|
std::string platform;
|
||||||
|
std::vector<std::pair<std::string, std::string>> values; // pairs of vulkan enum value and corresponding vk::-namespace enum value
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HandleData
|
struct HandleData
|
||||||
|
Loading…
x
Reference in New Issue
Block a user