Resolve instantiation issue with structures that are flagged as returnedonly (#382)

- make layout-structure default constructor an empty function
- introduce default constructor for the corresponding (non-layout) structure, delegating to the layout-structure's constructor
- introduce copy- and assignment constructors from the corresponding vulkan-structure, delegating to the copy- and assignment constructor from the layout-structure
This commit is contained in:
Andreas Süßenbach 2019-09-18 08:47:17 +02:00 committed by Markus Tavenrath
parent a12c3807de
commit a9a4860591
2 changed files with 1933 additions and 866 deletions

View File

@ -2346,6 +2346,8 @@ std::string VulkanHppGenerator::appendStructConstructor(std::pair<std::string, S
std::string arguments, initializers, copyOps; std::string arguments, initializers, copyOps;
bool listedArgument = false; bool listedArgument = false;
bool firstArgument = true; bool firstArgument = true;
if (!structData.second.returnedOnly)
{
for (auto const& member : structData.second.members) for (auto const& member : structData.second.members)
{ {
// gather the arguments // gather the arguments
@ -2383,11 +2385,12 @@ std::string VulkanHppGenerator::appendStructConstructor(std::pair<std::string, S
{ {
copyOps += "\n" + prefix; copyOps += "\n" + prefix;
} }
}
std::string structConstructor = prefix + stripPrefix(structData.first, "Vk") + (arguments.empty() ? "()\n" : std::string("( " + arguments + " )")) + "\n"; std::string structConstructor = prefix + stripPrefix(structData.first, "Vk") + (arguments.empty() ? "()" : std::string("( " + arguments + " )")) + "\n";
if (withLayoutStructure) if (withLayoutStructure)
{ {
structConstructor += prefix + " : layout::" + stripPrefix(structData.first, "Vk") + "( " + initializers + " )\n" + prefix + "{}\n"; structConstructor += prefix + " : layout::" + stripPrefix(structData.first, "Vk") + (initializers.empty() ? "()" : std::string("( " + initializers + " )")) + "\n" + prefix + "{}\n";
} }
else else
{ {
@ -2479,7 +2482,7 @@ void VulkanHppGenerator::appendStructCopyConstructors(std::string & str, std::st
${name}& operator=( Vk${name} const & rhs ) ${name}& operator=( Vk${name} const & rhs )
{ {
*reinterpret_cast<Vk${name}*>(this) = rhs; layout::${name}::operator=(rhs);
return *this; return *this;
} }
)"; )";
@ -2596,12 +2599,11 @@ ${members} };
}); });
} }
// only structs that are not returnedOnly get a constructor! std::string constructorAndSetters = appendStructConstructor(structure, " ", withLayoutStructure);
std::string constructorAndSetters; appendStructCopyConstructors(constructorAndSetters, stripPrefix(structure.first, "Vk"), withLayoutStructure);
if (!structure.second.returnedOnly) if (!structure.second.returnedOnly)
{ {
constructorAndSetters += appendStructConstructor(structure, " ", withLayoutStructure); // only structs that are not returnedOnly get setters!
appendStructCopyConstructors(constructorAndSetters, stripPrefix(structure.first, "Vk"), withLayoutStructure);
for (auto const& member : structure.second.members) for (auto const& member : structure.second.members)
{ {
appendStructSetter(constructorAndSetters, stripPrefix(structure.first, "Vk"), member); appendStructSetter(constructorAndSetters, stripPrefix(structure.first, "Vk"), member);

File diff suppressed because it is too large Load Diff