Improve handling of local Variables in enhanced simple functions.

This commit is contained in:
asuessenbach 2020-08-17 10:21:39 +02:00
parent 1eaee05676
commit 03eb851f81
2 changed files with 10 additions and 8 deletions

View File

@ -901,7 +901,7 @@ void VulkanHppGenerator::appendArguments( std::string & str,
}
else if ( beginsWith( commandData.params[i].type.type, "Vk" ) )
{
appendArgumentVulkanType( str, commandData.params[i] );
appendArgumentVulkanType( str, commandData.params[i], returnParamIndex == i );
}
else
{
@ -956,7 +956,9 @@ void VulkanHppGenerator::appendArgumentVector( std::string & str,
}
}
void VulkanHppGenerator::appendArgumentVulkanType( std::string & str, ParamData const & paramData ) const
void VulkanHppGenerator::appendArgumentVulkanType( std::string & str,
ParamData const & paramData,
bool isLocalVariable ) const
{
// this parameter is a vulkan type
if ( !paramData.type.postfix.empty() || !paramData.arraySizes.empty() )
@ -968,15 +970,15 @@ void VulkanHppGenerator::appendArgumentVulkanType( std::string & str, ParamData
appendReinterpretCast(
str, paramData.type.prefix.find( "const" ) != std::string::npos, paramData.type.type, false );
str += "( ";
if ( paramData.optional )
if ( isLocalVariable || !paramData.optional )
{
// for an optional parameter, we need also a static_cast from optional type to const-pointer to pure type
str += "static_cast<const " + stripPrefix( paramData.type.type, "Vk" ) + "*>( " + parameterName + " )";
// those parameters can just use the pointer
str += ( paramData.arraySizes.empty() ? "&" : "" ) + parameterName;
}
else
{
// other parameters can just use the pointer
str += ( paramData.arraySizes.empty() ? "&" : "" ) + parameterName;
// for an optional parameter, we need also a static_cast from optional type to const-pointer to pure type
str += "static_cast<const " + stripPrefix( paramData.type.type, "Vk" ) + "*>( " + parameterName + " )";
}
str += " )";
}

View File

@ -267,7 +267,7 @@ private:
bool twoStep,
bool firstCall,
bool singular ) const;
void appendArgumentVulkanType( std::string & str, ParamData const & paramData ) const;
void appendArgumentVulkanType( std::string & str, ParamData const & paramData, bool isLocalVariable ) const;
void appendBitmask( std::string & os,
std::string const & bitmaskName,
std::string const & bitmaskType,