Merge pull request #839 from asuessenbach/assert

Hold structure member attribute "optional" as a vector of bool.
This commit is contained in:
Andreas Süßenbach 2020-12-10 12:59:29 +01:00 committed by GitHub
commit 79ad327691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -5682,7 +5682,6 @@ void VulkanHppGenerator::appendStructConstructorsEnhanced( std::string &
if ( litit != lenIts.end() )
{
// len arguments just have an initalizer, from the ArrayProxyNoTemporaries size
assert( ( litit->second.size() == 1 ) || !litit->second.front()->optional );
initializers +=
( firstArgument ? ": " : ", " ) + mit->name + "( " + generateLenInitializer( mit, litit ) + " )";
sizeChecks += generateSizeCheck( litit->second, stripPrefix( structData.first, "Vk" ), prefix );
@ -7162,16 +7161,16 @@ std::string
std::string secondName = startLowerCase( stripPrefix( arrayIts[second]->name, "p" ) ) + "_";
std::string assertionCheck = firstName + ".size() == " + secondName + ".size()";
std::string throwCheck = firstName + ".size() != " + secondName + ".size()";
if ( arrayIts[first]->optional || arrayIts[second]->optional )
if ( ( !arrayIts[first]->optional.empty() && arrayIts[first]->optional.front() ) || ( !arrayIts[second]->optional.empty() && arrayIts[second]->optional.front() ) )
{
assertionCheck = "( " + assertionCheck + " )";
throwCheck = "( " + throwCheck + " )";
if ( arrayIts[second]->optional )
if ( !arrayIts[second]->optional.empty() && arrayIts[second]->optional.front() )
{
assertionCheck = secondName + ".empty() || " + assertionCheck;
throwCheck = "!" + secondName + ".empty() && " + throwCheck;
}
if ( arrayIts[first]->optional )
if ( !arrayIts[first]->optional.empty() && arrayIts[first]->optional.front() )
{
assertionCheck = firstName + ".empty() || " + assertionCheck;
throwCheck = "!" + firstName + ".empty() && " + throwCheck;
@ -9288,7 +9287,12 @@ void VulkanHppGenerator::readStructMember( tinyxml2::XMLElement const * element,
}
else if ( attribute.first == "optional" )
{
memberData.optional = ( attribute.second == "true" );
std::vector<std::string> optional = tokenize( attribute.second, "," );
memberData.optional.reserve( optional.size() );
for ( auto const & o : optional )
{
memberData.optional.push_back( o == "true" );
}
}
else if ( attribute.first == "selection" )
{

View File

@ -222,7 +222,7 @@ private:
std::string bitCount;
std::vector<std::string> len;
bool noAutoValidity = false;
bool optional = false;
std::vector<bool> optional;
std::string selection;
std::string selector;
std::vector<std::string> values;

View File

@ -17850,13 +17850,13 @@ namespace VULKAN_HPP_NAMESPACE
, scratchData( scratchData_ )
{
# ifdef VULKAN_HPP_NO_EXCEPTIONS
VULKAN_HPP_ASSERT( geometries_.size() == pGeometries_.size() );
VULKAN_HPP_ASSERT( geometries_.empty() || pGeometries_.empty() || ( geometries_.size() == pGeometries_.size() ) );
# else
if ( geometries_.size() != pGeometries_.size() )
if ( !geometries_.empty() && !pGeometries_.empty() && ( geometries_.size() != pGeometries_.size() ) )
{
throw LogicError(
VULKAN_HPP_NAMESPACE_STRING
"::AccelerationStructureBuildGeometryInfoKHR::AccelerationStructureBuildGeometryInfoKHR: geometries_.size() != pGeometries_.size()" );
"::AccelerationStructureBuildGeometryInfoKHR::AccelerationStructureBuildGeometryInfoKHR: !geometries_.empty() && !pGeometries_.empty() && ( geometries_.size() != pGeometries_.size() )" );
}
# endif /*VULKAN_HPP_NO_EXCEPTIONS*/
}