List out default ctor parameters in separate lines (#225)

It's often useful to browse through vulkan.hpp to check what the default values
for various info structs are, but having them on a single line makes it hard to
read.

This change puts each ctor argument on a different line, which makes the
default values more visible.
This commit is contained in:
Markus Tavenrath 2018-06-12 09:58:52 +02:00 committed by GitHub
parent 3f9ca5433a
commit eaf0fda6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 974 additions and 220 deletions

View File

@ -3996,11 +3996,14 @@ void VulkanHppGenerator::writeResultEnum(std::ostream & os)
void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues)
{
// the constructor with all the elements as arguments, with defaults
os << " " << name << "( ";
std::string ctorOpening = " " + name + "( ";
size_t indentSize = ctorOpening.size();
os << ctorOpening;
bool listedArgument = false;
for (size_t i = 0; i < structData.members.size(); i++)
{
listedArgument = writeStructConstructorArgument(os, listedArgument, structData.members[i], defaultValues);
listedArgument = writeStructConstructorArgument(os, listedArgument, indentSize, structData.members[i], defaultValues);
}
os << " )" << std::endl;
@ -4045,11 +4048,14 @@ void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string c
assert(subStruct != m_structs.end());
std::string subStructArgumentName = startLowerCase(strip(subStruct->first, "vk"));
std::string ctorOpening = " explicit " + name + "( ";
size_t indentSize = ctorOpening.size();
os << ctorOpening << subStruct->first << " const& " << subStructArgumentName;
os << " explicit " << name << "( " << subStruct->first << " const& " << subStructArgumentName;
for (size_t i = subStruct->second.members.size(); i < structData.members.size(); i++)
{
writeStructConstructorArgument(os, true, structData.members[i], defaultValues);
writeStructConstructorArgument(os, true, indentSize, structData.members[i], defaultValues);
}
os << " )" << std::endl;
@ -4092,12 +4098,22 @@ void VulkanHppGenerator::writeStructConstructor(std::ostream & os, std::string c
os << replaceWithMap(templateString, { { "name", name } });
}
bool VulkanHppGenerator::writeStructConstructorArgument(std::ostream & os, bool listedArgument, MemberData const& memberData, std::map<std::string, std::string> const& defaultValues)
void VulkanHppGenerator::writeIndentation(std::ostream & os, size_t indentLength)
{
for(size_t i = 0; i < indentLength; i++)
{
os << " ";
}
}
bool VulkanHppGenerator::writeStructConstructorArgument(std::ostream & os, bool listedArgument, size_t indentLength, MemberData const& memberData, std::map<std::string, std::string> const& defaultValues)
{
if (listedArgument)
{
os << ", ";
os << ",\n";
writeIndentation(os, indentLength);
}
// skip members 'pNext' and 'sType', as they are never explicitly set
if ((memberData.name != "pNext") && (memberData.name != "sType"))
{

View File

@ -270,8 +270,9 @@ class VulkanHppGenerator
void writeFunctionHeaderArgumentsStandard(std::ostream & os, CommandData const& commandData, bool withDefaults);
void writeFunctionHeaderReturnType(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool singular, bool unique, bool isStructureChain);
void writeFunctionHeaderTemplate(std::ostream & os, std::string const& indentation, CommandData const& commandData, bool enhanced, bool unique, bool withDefault, bool isStructureChain);
void writeIndentation(std::ostream & os, size_t indentLength);
void writeStructConstructor(std::ostream & os, std::string const& name, StructData const& structData, std::map<std::string, std::string> const& defaultValues);
bool writeStructConstructorArgument(std::ostream & os, bool listedArgument, MemberData const& memberData, std::map<std::string, std::string> const& defaultValues);
bool writeStructConstructorArgument(std::ostream & os, bool listedArgument, size_t indentLength, MemberData const& memberData, std::map<std::string, std::string> const& defaultValues);
void writeStructSetter(std::ostream & os, std::string const& structureName, MemberData const& memberData);
void writeStructureChainValidation(std::ostream & os, DependencyData const& dependencyData);
void writeThrowExceptions(std::ostream& os, EnumData const& enumData);

File diff suppressed because it is too large Load Diff