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

View File

@ -267,7 +267,7 @@ private:
bool twoStep, bool twoStep,
bool firstCall, bool firstCall,
bool singular ) const; 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, void appendBitmask( std::string & os,
std::string const & bitmaskName, std::string const & bitmaskName,
std::string const & bitmaskType, std::string const & bitmaskType,