From 183d08fed70b6816d4b91735b1afd2862101b44f Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Wed, 5 May 2021 09:28:00 +0200 Subject: [PATCH] Add check on commands that do not return a VkResult, but specify errorcodes or successcodes. --- VulkanHppGenerator.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 9d474ba..a3e2944 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -18,7 +18,6 @@ #include #include -void appendReinterpretCast( std::string & str, bool leadingConst, std::string const & type ); void appendTypesafeStuff( std::string & str, std::string const & typesafeCheck ); void appendVersionCheck( std::string & str, std::string const & version ); bool beginsWith( std::string const & text, std::string const & prefix ); @@ -86,16 +85,6 @@ const std::set specialPointerTypes = { "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 ) { str += @@ -880,8 +869,12 @@ void VulkanHppGenerator::appendArgumentVector( std::string & str, // CHECK for !commandData.params[it->first].optional // 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 += "( " + parameterName + ".data() )"; + str += "reinterpret_cast<"; + if ( paramData.type.prefix.find( "const" ) == 0 ) + { + str += "const "; + } + str += paramData.type.type + "*>( " + parameterName + ".data() )"; } else { @@ -12457,6 +12450,12 @@ void VulkanHppGenerator::readCommand( tinyxml2::XMLElement const * } } 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 ) ); addCommand( name, commandData );