mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Fix issue #45: provide non-const getters
This commit is contained in:
parent
9c6888edf3
commit
ae7d0fe00b
@ -216,6 +216,10 @@ struct MemberData
|
|||||||
|
|
||||||
struct StructData
|
struct StructData
|
||||||
{
|
{
|
||||||
|
StructData()
|
||||||
|
: returnedOnly(false)
|
||||||
|
{}
|
||||||
|
|
||||||
bool returnedOnly;
|
bool returnedOnly;
|
||||||
std::vector<MemberData> members;
|
std::vector<MemberData> members;
|
||||||
std::string protect;
|
std::string protect;
|
||||||
@ -338,7 +342,7 @@ void writeExceptionCheck(std::ofstream & ofs, std::string const& indentation, st
|
|||||||
void writeFunctionHeader(std::ofstream & ofs, std::string const& indentation, std::string const& returnType, std::string const& name, CommandData const& commandData, size_t returnIndex, size_t templateIndex, std::map<size_t, size_t> const& vectorParameters);
|
void writeFunctionHeader(std::ofstream & ofs, std::string const& indentation, std::string const& returnType, std::string const& name, CommandData const& commandData, size_t returnIndex, size_t templateIndex, std::map<size_t, size_t> const& vectorParameters);
|
||||||
void writeMemberData(std::ofstream & ofs, MemberData const& memberData, std::set<std::string> const& vkTypes);
|
void writeMemberData(std::ofstream & ofs, MemberData const& memberData, std::set<std::string> const& vkTypes);
|
||||||
void writeStructConstructor( std::ofstream & ofs, std::string const& name, std::string const& memberName, StructData const& structData, std::set<std::string> const& vkTypes, std::map<std::string,std::string> const& defaultValues );
|
void writeStructConstructor( std::ofstream & ofs, std::string const& name, std::string const& memberName, StructData const& structData, std::set<std::string> const& vkTypes, std::map<std::string,std::string> const& defaultValues );
|
||||||
void writeStructGetter( std::ofstream & ofs, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes );
|
void writeStructGetter( std::ofstream & ofs, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes, bool constVersion );
|
||||||
void writeStructSetter( std::ofstream & ofs, std::string const& name, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes, std::map<std::string,StructData> const& structs );
|
void writeStructSetter( std::ofstream & ofs, std::string const& name, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes, std::map<std::string,StructData> const& structs );
|
||||||
void writeTypeCommand( std::ofstream & ofs, DependencyData const& dependencyData, CommandData const& commandData, std::set<std::string> const& vkTypes );
|
void writeTypeCommand( std::ofstream & ofs, DependencyData const& dependencyData, CommandData const& commandData, std::set<std::string> const& vkTypes );
|
||||||
void writeTypeCommandEnhanced(std::ofstream & ofs, std::string const& indentation, std::string const& className, DependencyData const& dependencyData, CommandData const& commandData, std::set<std::string> const& vkTypes);
|
void writeTypeCommandEnhanced(std::ofstream & ofs, std::string const& indentation, std::string const& className, DependencyData const& dependencyData, CommandData const& commandData, std::set<std::string> const& vkTypes);
|
||||||
@ -1843,12 +1847,12 @@ void writeStructConstructor( std::ofstream & ofs, std::string const& name, std::
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeStructGetter( std::ofstream & ofs, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes )
|
void writeStructGetter( std::ofstream & ofs, MemberData const& memberData, std::string const& memberName, std::set<std::string> const& vkTypes, bool constVersion )
|
||||||
{
|
{
|
||||||
ofs << " ";
|
ofs << " ";
|
||||||
if ( memberData.type.back() == '*' )
|
if ( memberData.type.back() == '*' )
|
||||||
{
|
{
|
||||||
if ( memberData.type.find( "const" ) != 0 )
|
if ( constVersion && ( memberData.type.find( "const" ) != 0 ) )
|
||||||
{
|
{
|
||||||
ofs << "const ";
|
ofs << "const ";
|
||||||
}
|
}
|
||||||
@ -1856,23 +1860,47 @@ void writeStructGetter( std::ofstream & ofs, MemberData const& memberData, std::
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ofs << "const " << memberData.type << ( memberData.arraySize.empty() ? '&' : '*' );
|
if (constVersion)
|
||||||
|
{
|
||||||
|
ofs << "const ";
|
||||||
|
}
|
||||||
|
ofs << memberData.type << ( memberData.arraySize.empty() ? '&' : '*' );
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs << " " << memberData.name << "() const" << std::endl
|
ofs << " " << memberData.name << "()";
|
||||||
|
if (constVersion)
|
||||||
|
{
|
||||||
|
ofs << " const";
|
||||||
|
}
|
||||||
|
ofs << std::endl
|
||||||
<< " {" << std::endl
|
<< " {" << std::endl
|
||||||
<< " return ";
|
<< " return ";
|
||||||
if ( ! memberData.arraySize.empty() )
|
if ( ! memberData.arraySize.empty() )
|
||||||
{
|
{
|
||||||
ofs << "reinterpret_cast<const " << memberData.type << "*>( " << memberName << "." << memberData.name << " )";
|
ofs << "reinterpret_cast<";
|
||||||
|
if (constVersion)
|
||||||
|
{
|
||||||
|
ofs << "const ";
|
||||||
|
}
|
||||||
|
ofs << memberData.type << "*>( " << memberName << "." << memberData.name << " )";
|
||||||
}
|
}
|
||||||
else if ( memberData.type.back() == '*' )
|
else if ( memberData.type.back() == '*' )
|
||||||
{
|
{
|
||||||
ofs << "reinterpret_cast<" << memberData.type << ">( " << memberName << "." << memberData.name << " )";
|
ofs << "reinterpret_cast<";
|
||||||
|
if (constVersion && (memberData.type.find("const") != 0))
|
||||||
|
{
|
||||||
|
ofs << "const ";
|
||||||
|
}
|
||||||
|
ofs << memberData.type << ">( " << memberName << "." << memberData.name << " )";
|
||||||
}
|
}
|
||||||
else if ( vkTypes.find( memberData.pureType ) != vkTypes.end() )
|
else if ( vkTypes.find( memberData.pureType ) != vkTypes.end() )
|
||||||
{
|
{
|
||||||
ofs << "reinterpret_cast<const " << memberData.pureType << "&>( " << memberName << "." << memberData.name << " )";
|
ofs << "reinterpret_cast<";
|
||||||
|
if (constVersion)
|
||||||
|
{
|
||||||
|
ofs << "const ";
|
||||||
|
}
|
||||||
|
ofs << memberData.pureType << "&>( " << memberName << "." << memberData.name << " )";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2548,9 +2576,10 @@ void writeTypeStruct( std::ofstream & ofs, DependencyData const& dependencyData,
|
|||||||
// create the getters and setters
|
// create the getters and setters
|
||||||
for ( size_t i=0 ; i<it->second.members.size() ; i++ )
|
for ( size_t i=0 ; i<it->second.members.size() ; i++ )
|
||||||
{
|
{
|
||||||
writeStructGetter( ofs, it->second.members[i], memberName, vkTypes );
|
writeStructGetter(ofs, it->second.members[i], memberName, vkTypes, true);
|
||||||
if ( !it->second.returnedOnly )
|
if (!it->second.returnedOnly)
|
||||||
{
|
{
|
||||||
|
writeStructGetter(ofs, it->second.members[i], memberName, vkTypes, false);
|
||||||
writeStructSetter( ofs, dependencyData.name, it->second.members[i], memberName, vkTypes );
|
writeStructSetter( ofs, dependencyData.name, it->second.members[i], memberName, vkTypes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2634,8 +2663,11 @@ void writeTypeUnion( std::ofstream & ofs, DependencyData const& dependencyData,
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// one getter/setter per union element
|
// one getter/setter per union element
|
||||||
writeStructGetter( ofs, unionData.members[i], memberName, vkTypes );
|
writeStructGetter(ofs, unionData.members[i], memberName, vkTypes, true);
|
||||||
writeStructSetter( ofs, dependencyData.name, unionData.members[i], memberName, vkTypes );
|
|
||||||
|
assert(!unionData.returnedOnly);
|
||||||
|
writeStructGetter(ofs, unionData.members[i], memberName, vkTypes, false);
|
||||||
|
writeStructSetter(ofs, dependencyData.name, unionData.members[i], memberName, vkTypes);
|
||||||
}
|
}
|
||||||
ofs << " operator Vk" << dependencyData.name << " const& () const" << std::endl
|
ofs << " operator Vk" << dependencyData.name << " const& () const" << std::endl
|
||||||
<< " {" << std::endl
|
<< " {" << std::endl
|
||||||
|
3550
vulkan/vk_cpp.h
3550
vulkan/vk_cpp.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user