Correct default initializer for array of enums.

This commit is contained in:
asuessenbach 2020-04-29 11:45:10 +02:00
parent f84dfab162
commit c6f4dfb79b
2 changed files with 11 additions and 14 deletions

View File

@ -1825,8 +1825,7 @@ void VulkanHppGenerator::appendEnums( std::string & str ) const
void VulkanHppGenerator::appendEnumInitializer( std::string & str, void VulkanHppGenerator::appendEnumInitializer( std::string & str,
TypeData const & type, TypeData const & type,
std::vector<std::string> const & arraySizes, std::vector<std::string> const & arraySizes,
std::vector<EnumValueData> const & values, std::vector<EnumValueData> const & values ) const
bool argument ) const
{ {
// enum arguments might need special initialization // enum arguments might need special initialization
assert( type.prefix.empty() && !values.empty() ); assert( type.prefix.empty() && !values.empty() );
@ -1840,13 +1839,12 @@ void VulkanHppGenerator::appendEnumInitializer( std::string &
assert( arraySizes.size() == 1 ); assert( arraySizes.size() == 1 );
int count = std::stoi( arraySizes[0] ); int count = std::stoi( arraySizes[0] );
assert( 1 < count ); assert( 1 < count );
str += argument ? "{ { " : "{ "; // for function arguments, we need two braces, for default initializers just one str += "{ { " + value;
str += value;
for ( int i = 1; i < count; i++ ) for ( int i = 1; i < count; i++ )
{ {
str += ", " + value; str += ", " + value;
} }
str += argument ? " } }" : " }"; str += " } }";
} }
} }
@ -3594,7 +3592,7 @@ bool VulkanHppGenerator::appendStructConstructorArgument( std::string & st
auto enumIt = m_enums.find( memberData.type.type ); auto enumIt = m_enums.find( memberData.type.type );
if ( enumIt != m_enums.end() && memberData.type.postfix.empty() ) if ( enumIt != m_enums.end() && memberData.type.postfix.empty() )
{ {
appendEnumInitializer( str, memberData.type, memberData.arraySizes, enumIt->second.values, true ); appendEnumInitializer( str, memberData.type, memberData.arraySizes, enumIt->second.values );
} }
else else
{ {
@ -3690,7 +3688,7 @@ std::string VulkanHppGenerator::appendStructMembers( std::string &
auto enumIt = m_enums.find( member.type.type ); auto enumIt = m_enums.find( member.type.type );
if ( enumIt != m_enums.end() && member.type.postfix.empty() ) if ( enumIt != m_enums.end() && member.type.postfix.empty() )
{ {
appendEnumInitializer( str, member.type, member.arraySizes, enumIt->second.values, false ); appendEnumInitializer( str, member.type, member.arraySizes, enumIt->second.values );
} }
else else
{ {
@ -4438,9 +4436,9 @@ size_t VulkanHppGenerator::determineReturnParamIndex( CommandData const &
( vpit->second == INVALID_INDEX ) || ( vpit->second == INVALID_INDEX ) ||
( commandData.params[vpit->second].type.postfix.find( '*' ) != std::string::npos ) ) ( commandData.params[vpit->second].type.postfix.find( '*' ) != std::string::npos ) )
{ {
// it's not a vector parameter, or a two-step process, or there is at least one more vector parameter, or the // it's not a vector parameter, or a two-step process, or there is at least one more vector parameter, or
// size argument of this vector parameter is not an argument, or the size argument of this vector parameter is // the size argument of this vector parameter is not an argument, or the size argument of this vector
// provided by a pointer // parameter is provided by a pointer
// -> look for another non-cost pointer argument // -> look for another non-cost pointer argument
auto paramIt = auto paramIt =
std::find_if( commandData.params.begin() + i + 1, commandData.params.end(), []( ParamData const & pd ) { std::find_if( commandData.params.begin() + i + 1, commandData.params.end(), []( ParamData const & pd ) {
@ -4521,8 +4519,8 @@ std::map<size_t, size_t> VulkanHppGenerator::determineVectorParamIndices( std::v
assert( ( std::count_if( params.begin(), params.end(), findLambda ) == 0 ) || assert( ( std::count_if( params.begin(), params.end(), findLambda ) == 0 ) ||
( findIt < it ) ); // make sure, there is no other parameter like that ( findIt < it ) ); // make sure, there is no other parameter like that
// add this parameter as a vector parameter, using the len-name parameter as the second value (or INVALID_INDEX if // add this parameter as a vector parameter, using the len-name parameter as the second value (or INVALID_INDEX
// there is nothing like that) // if there is nothing like that)
vectorParamIndices.insert( vectorParamIndices.insert(
std::make_pair( std::distance( params.begin(), it ), std::make_pair( std::distance( params.begin(), it ),
( findIt < it ) ? std::distance( params.begin(), findIt ) : INVALID_INDEX ) ); ( findIt < it ) ? std::distance( params.begin(), findIt ) : INVALID_INDEX ) );

View File

@ -267,8 +267,7 @@ private:
void appendEnumInitializer( std::string & str, void appendEnumInitializer( std::string & str,
TypeData const & type, TypeData const & type,
std::vector<std::string> const & arraySizes, std::vector<std::string> const & arraySizes,
std::vector<EnumValueData> const & values, std::vector<EnumValueData> const & values ) const;
bool argument ) const;
void appendEnumToString( std::string & str, std::pair<std::string, EnumData> const & enumData ) const; void appendEnumToString( std::string & str, std::pair<std::string, EnumData> const & enumData ) const;
void appendFunction( std::string & str, void appendFunction( std::string & str,
std::string const & indentation, std::string const & indentation,