Removed default arguments from standard versions of functions, and the shortened function versions of destroy* and free*

This is needed to prevent compiler ambiguities!
This commit is contained in:
asuessenbach 2020-11-02 11:51:07 +01:00
parent a4aeabb770
commit 2a700aaa74
3 changed files with 422 additions and 444 deletions

View File

@ -1048,7 +1048,6 @@ void VulkanHppGenerator::appendCall( std::string & str,
} }
void VulkanHppGenerator::appendCommand( std::string & str, void VulkanHppGenerator::appendCommand( std::string & str,
std::string const & indentation,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
bool definition ) const bool definition ) const
@ -1269,7 +1268,7 @@ void VulkanHppGenerator::appendCommand( std::string & str,
aliasCommandData.extensions = ad.second.extensions; aliasCommandData.extensions = ad.second.extensions;
aliasCommandData.feature = ad.second.feature; aliasCommandData.feature = ad.second.feature;
aliasCommandData.xmlLine = ad.second.xmlLine; aliasCommandData.xmlLine = ad.second.xmlLine;
appendCommand( str, indentation, ad.first, aliasCommandData, definition ); appendCommand( str, ad.first, aliasCommandData, definition );
} }
} }
return; return;
@ -2593,7 +2592,7 @@ void VulkanHppGenerator::appendHandle( std::string & str, std::pair<std::string,
appendUniqueTypes( str, "", { "VkInstance" } ); appendUniqueTypes( str, "", { "VkInstance" } );
} }
str += "\n"; str += "\n";
appendCommand( str, " ", commandIt->first, commandIt->second, false ); appendCommand( str, commandIt->first, commandIt->second, false );
} }
} }
else else
@ -2619,7 +2618,7 @@ void VulkanHppGenerator::appendHandle( std::string & str, std::pair<std::string,
std::string commandString; std::string commandString;
std::string commandName = determineCommandName( commandIt->first, commandIt->second.params[0].type.type ); std::string commandName = determineCommandName( commandIt->first, commandIt->second.params[0].type.type );
commands += "\n"; commands += "\n";
appendCommand( commands, " ", commandIt->first, commandIt->second, false ); appendCommand( commands, commandIt->first, commandIt->second, false );
// special handling for destroy functions // special handling for destroy functions
if ( ( ( commandIt->first.substr( 2, 7 ) == "Destroy" ) && ( commandName != "destroy" ) ) || if ( ( ( commandIt->first.substr( 2, 7 ) == "Destroy" ) && ( commandName != "destroy" ) ) ||
@ -2635,7 +2634,7 @@ void VulkanHppGenerator::appendHandle( std::string & str, std::pair<std::string,
commandData.extensions.clear(); commandData.extensions.clear();
commandData.feature.clear(); commandData.feature.clear();
} }
appendCommand( destroyCommandString, " ", commandIt->first, commandData, false ); appendCommand( destroyCommandString, commandIt->first, commandData, false );
std::string shortenedName; std::string shortenedName;
if ( commandIt->first.substr( 2, 7 ) == "Destroy" ) if ( commandIt->first.substr( 2, 7 ) == "Destroy" )
{ {
@ -2656,6 +2655,17 @@ void VulkanHppGenerator::appendHandle( std::string & str, std::pair<std::string,
destroyCommandString.replace( pos, commandName.length(), shortenedName ); destroyCommandString.replace( pos, commandName.length(), shortenedName );
pos = destroyCommandString.find( commandName, pos ); pos = destroyCommandString.find( commandName, pos );
} }
// we need to remove the default argument for the first argument, to prevent ambiguities!
assert( 1 < commandIt->second.params.size() );
pos = destroyCommandString.find( commandIt->second.params[1].name ); // skip the standard version of the function
assert(pos != std::string::npos);
pos = destroyCommandString.find( commandIt->second.params[1].name, pos + 1 ); // get the argument to destroy in the advanced version
assert( pos != std::string::npos );
pos = destroyCommandString.find( " VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT", pos );
if ( pos != std::string::npos )
{
destroyCommandString.erase( pos, strlen( " VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT" ) );
}
commands += "\n" + destroyCommandString; commands += "\n" + destroyCommandString;
} }
} }
@ -2826,7 +2836,7 @@ void VulkanHppGenerator::appendHandlesCommandDefinitions( std::string & str ) co
std::string strippedName = startLowerCase( stripPrefix( commandIt->first, "vk" ) ); std::string strippedName = startLowerCase( stripPrefix( commandIt->first, "vk" ) );
str += "\n"; str += "\n";
appendCommand( str, " ", commandIt->first, commandIt->second, true ); appendCommand( str, commandIt->first, commandIt->second, true );
// special handling for destroy functions // special handling for destroy functions
std::string commandName = determineCommandName( commandIt->first, commandIt->second.params[0].type.type ); std::string commandName = determineCommandName( commandIt->first, commandIt->second.params[0].type.type );
@ -2846,7 +2856,7 @@ void VulkanHppGenerator::appendHandlesCommandDefinitions( std::string & str ) co
commandData.feature.clear(); commandData.feature.clear();
} }
appendCommand( destroyCommandString, " ", commandIt->first, commandData, true ); appendCommand( destroyCommandString, commandIt->first, commandData, true );
std::string shortenedName; std::string shortenedName;
if ( commandIt->first.substr( 2, 7 ) == "Destroy" ) if ( commandIt->first.substr( 2, 7 ) == "Destroy" )
{ {
@ -2867,6 +2877,19 @@ void VulkanHppGenerator::appendHandlesCommandDefinitions( std::string & str ) co
destroyCommandString.replace( pos, commandName.length(), shortenedName ); destroyCommandString.replace( pos, commandName.length(), shortenedName );
pos = destroyCommandString.find( commandName, pos ); pos = destroyCommandString.find( commandName, pos );
} }
// we need to remove the default argument for the first argument, to prevent ambiguities!
assert( 1 < commandIt->second.params.size() );
pos =
destroyCommandString.find( commandIt->second.params[1].name ); // skip the standard version of the function
assert( pos != std::string::npos );
pos = destroyCommandString.find( commandIt->second.params[1].name,
pos + 1 ); // get the argument to destroy in the advanced version
assert( pos != std::string::npos );
pos = destroyCommandString.find( " VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT", pos );
if ( pos != std::string::npos )
{
destroyCommandString.erase( pos, strlen( " VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT" ) );
}
if ( complex ) if ( complex )
{ {
@ -3202,21 +3225,15 @@ std::string VulkanHppGenerator::constructArgumentListEnhanced( std::vector<Param
} }
std::string VulkanHppGenerator::constructArgumentListStandard( std::vector<ParamData> const & params, std::string VulkanHppGenerator::constructArgumentListStandard( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams, std::set<size_t> const & skippedParams ) const
bool definition ) const
{ {
size_t defaultStartIndex = determineDefaultStartIndex( params, skippedParams );
std::string argumentList; std::string argumentList;
for ( size_t i = 0; i < params.size(); ++i ) for ( size_t i = 0; i < params.size(); ++i )
{ {
if ( skippedParams.find( i ) == skippedParams.end() ) if ( skippedParams.find( i ) == skippedParams.end() )
{ {
argumentList += argumentList +=
params[i].type.compose() + " " + params[i].name + constructCArraySizes( params[i].arraySizes ) + params[i].type.compose() + " " + params[i].name + constructCArraySizes( params[i].arraySizes ) + ", ";
( !definition && params[i].optional && ( defaultStartIndex <= i ) ? " VULKAN_HPP_DEFAULT_ARGUMENT_ASSIGNMENT"
: "" ) +
", ";
} }
} }
argumentList += "Dispatch const & d "; argumentList += "Dispatch const & d ";
@ -4797,7 +4814,7 @@ std::string VulkanHppGenerator::constructCommandStandard( std::string const & na
{ {
std::set<size_t> skippedParams = determineSkippedParams( commandData.handle, commandData.params, {}, {}, false ); std::set<size_t> skippedParams = determineSkippedParams( commandData.handle, commandData.params, {}, {}, false );
std::string argumentList = constructArgumentListStandard( commandData.params, skippedParams, definition ); std::string argumentList = constructArgumentListStandard( commandData.params, skippedParams );
std::string commandName = determineCommandName( name, commandData.params[0].type.type ); std::string commandName = determineCommandName( name, commandData.params[0].type.type );
std::string nodiscard = constructNoDiscardStandard( commandData ); std::string nodiscard = constructNoDiscardStandard( commandData );
std::string returnType = stripPrefix( commandData.returnType, "Vk" ); std::string returnType = stripPrefix( commandData.returnType, "Vk" );

View File

@ -308,7 +308,6 @@ private:
bool twoStep, bool twoStep,
bool firstCall ) const; bool firstCall ) const;
void appendCommand( std::string & str, void appendCommand( std::string & str,
std::string const & indentation,
std::string const & name, std::string const & name,
CommandData const & commandData, CommandData const & commandData,
bool definition ) const; bool definition ) const;
@ -471,8 +470,7 @@ private:
bool withAllocators, bool withAllocators,
bool structureChain ) const; bool structureChain ) const;
std::string constructArgumentListStandard( std::vector<ParamData> const & params, std::string constructArgumentListStandard( std::vector<ParamData> const & params,
std::set<size_t> const & skippedParams, std::set<size_t> const & skippedParams ) const;
bool definition ) const;
std::string constructCallArgument( ParamData const & param, bool enhanced ) const; std::string constructCallArgument( ParamData const & param, bool enhanced ) const;
std::string constructCallArgumentsEnumerateVectors( std::string const & handle, std::string constructCallArgumentsEnumerateVectors( std::string const & handle,
std::vector<ParamData> const & params, std::vector<ParamData> const & params,

File diff suppressed because it is too large Load Diff