Merge pull request #956 from asuessenbach/check

Add check on commands that do not return a VkResult, but specify errorcodes or successcodes.
This commit is contained in:
Andreas Süßenbach 2021-05-05 12:33:28 +02:00 committed by GitHub
commit e8d164dcf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,6 @@
#include <fstream> #include <fstream>
#include <regex> #include <regex>
void appendReinterpretCast( std::string & str, bool leadingConst, std::string const & type );
void appendTypesafeStuff( std::string & str, std::string const & typesafeCheck ); void appendTypesafeStuff( std::string & str, std::string const & typesafeCheck );
void appendVersionCheck( std::string & str, std::string const & version ); void appendVersionCheck( std::string & str, std::string const & version );
bool beginsWith( std::string const & text, std::string const & prefix ); bool beginsWith( std::string const & text, std::string const & prefix );
@ -86,16 +85,6 @@ const std::set<std::string> specialPointerTypes = {
"Display", "IDirectFB", "wl_display", "xcb_connection_t", "_screen_window" "Display", "IDirectFB", "wl_display", "xcb_connection_t", "_screen_window"
}; };
void appendReinterpretCast( std::string & str, bool leadingConst, std::string const & type )
{
str += "reinterpret_cast<";
if ( leadingConst )
{
str += "const ";
}
str += type + "*>";
}
void appendTypesafeStuff( std::string & str, std::string const & typesafeCheck ) void appendTypesafeStuff( std::string & str, std::string const & typesafeCheck )
{ {
str += str +=
@ -880,8 +869,12 @@ void VulkanHppGenerator::appendArgumentVector( std::string & str,
// CHECK for !commandData.params[it->first].optional // CHECK for !commandData.params[it->first].optional
// this parameter is a vulkan type or a templated type -> need to reinterpret cast // this parameter is a vulkan type or a templated type -> need to reinterpret cast
appendReinterpretCast( str, paramData.type.prefix.find( "const" ) == 0, paramData.type.type ); str += "reinterpret_cast<";
str += "( " + parameterName + ".data() )"; if ( paramData.type.prefix.find( "const" ) == 0 )
{
str += "const ";
}
str += paramData.type.type + "*>( " + parameterName + ".data() )";
} }
else else
{ {
@ -12457,6 +12450,12 @@ void VulkanHppGenerator::readCommand( tinyxml2::XMLElement const *
} }
} }
assert( !name.empty() ); assert( !name.empty() );
check( ( commandData.returnType == "VkResult" ) || commandData.errorCodes.empty(),
line,
"command <" + name + "> does not return a VkResult but specifies errorcodes" );
check( ( commandData.returnType == "VkResult" ) || commandData.successCodes.empty(),
line,
"command <" + name + "> does not return a VkResult but specifies successcodes" );
registerDeleter( name, std::make_pair( name, commandData ) ); registerDeleter( name, std::make_pair( name, commandData ) );
addCommand( name, commandData ); addCommand( name, commandData );