mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Use memcmp instead of operator==() to compare unknown types from external headers, as they might not support that operator.
This commit is contained in:
parent
6896223a3f
commit
c6a48460e8
@ -2774,8 +2774,8 @@ void VulkanHppGenerator::appendFunctionHeaderArgumentEnhancedVector( std::string
|
|||||||
// otherwise, use our ArrayProxy
|
// otherwise, use our ArrayProxy
|
||||||
bool isConst = ( param.type.prefix.find( "const" ) != std::string::npos );
|
bool isConst = ( param.type.prefix.find( "const" ) != std::string::npos );
|
||||||
str += optionalBegin + "ArrayProxy<" +
|
str += optionalBegin + "ArrayProxy<" +
|
||||||
( isTemplateParam ? ( isConst ? "const T" : "T" ) : stripPostfix( param.type.compose(), "*" ) ) + "> " + optionalEnd +
|
( isTemplateParam ? ( isConst ? "const T" : "T" ) : stripPostfix( param.type.compose(), "*" ) ) + "> " +
|
||||||
strippedParameterName;
|
optionalEnd + strippedParameterName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3490,13 +3490,30 @@ ${prefix}}
|
|||||||
void VulkanHppGenerator::appendStructCompareOperators( std::string & str,
|
void VulkanHppGenerator::appendStructCompareOperators( std::string & str,
|
||||||
std::pair<std::string, StructureData> const & structData ) const
|
std::pair<std::string, StructureData> const & structData ) const
|
||||||
{
|
{
|
||||||
|
static const std::set<std::string> simpleTypes = { "char", "double", "DWORD", "float", "HANDLE",
|
||||||
|
"HINSTANCE", "HMONITOR", "HWND", "int", "int8_t",
|
||||||
|
"int16_t", "int32_t", "int64_t", "LPCWSTR", "size_t",
|
||||||
|
"uint8_t", "uint16_t", "uint32_t", "uint64_t" };
|
||||||
// two structs are compared by comparing each of the elements
|
// two structs are compared by comparing each of the elements
|
||||||
std::string compareMembers;
|
std::string compareMembers;
|
||||||
std::string intro = "";
|
std::string intro = "";
|
||||||
for ( size_t i = 0; i < structData.second.members.size(); i++ )
|
for ( size_t i = 0; i < structData.second.members.size(); i++ )
|
||||||
{
|
{
|
||||||
MemberData const & member = structData.second.members[i];
|
MemberData const & member = structData.second.members[i];
|
||||||
|
auto typeIt = m_types.find( member.type.type );
|
||||||
|
assert( typeIt != m_types.end() );
|
||||||
|
if ( ( typeIt->second.category == TypeCategory::Requires ) && member.type.postfix.empty() &&
|
||||||
|
( simpleTypes.find( member.type.type ) == simpleTypes.end() ) )
|
||||||
|
{
|
||||||
|
// this type might support operator==()... that is, use memcmp
|
||||||
|
compareMembers +=
|
||||||
|
intro + "( memcmp( &" + member.name + ", &rhs." + member.name + ", sizeof( " + member.type.type + " ) ) == 0 )";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// for all others, we use the operator== of that type
|
||||||
compareMembers += intro + "( " + member.name + " == rhs." + member.name + " )";
|
compareMembers += intro + "( " + member.name + " == rhs." + member.name + " )";
|
||||||
|
}
|
||||||
intro = "\n && ";
|
intro = "\n && ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49197,7 +49197,7 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
bool operator==( ImagePipeSurfaceCreateInfoFUCHSIA const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator==( ImagePipeSurfaceCreateInfoFUCHSIA const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
||||||
( imagePipeHandle == rhs.imagePipeHandle );
|
( memcmp( &imagePipeHandle, &rhs.imagePipeHandle, sizeof( zx_handle_t ) ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( ImagePipeSurfaceCreateInfoFUCHSIA const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( ImagePipeSurfaceCreateInfoFUCHSIA const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
@ -70507,7 +70507,8 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
# else
|
# else
|
||||||
bool operator==( PresentFrameTokenGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator==( PresentFrameTokenGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( frameToken == rhs.frameToken );
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) &&
|
||||||
|
( memcmp( &frameToken, &rhs.frameToken, sizeof( GgpFrameToken ) ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( PresentFrameTokenGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( PresentFrameTokenGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
@ -76134,7 +76135,7 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
bool operator==( StreamDescriptorSurfaceCreateInfoGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator==( StreamDescriptorSurfaceCreateInfoGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
||||||
( streamDescriptor == rhs.streamDescriptor );
|
( memcmp( &streamDescriptor, &rhs.streamDescriptor, sizeof( GgpStreamDescriptor ) ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( StreamDescriptorSurfaceCreateInfoGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( StreamDescriptorSurfaceCreateInfoGGP const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
@ -79316,7 +79317,7 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
bool operator==( XcbSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator==( XcbSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) &&
|
||||||
( connection == rhs.connection ) && ( window == rhs.window );
|
( connection == rhs.connection ) && ( memcmp( &window, &rhs.window, sizeof( xcb_window_t ) ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( XcbSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( XcbSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
@ -79414,7 +79415,7 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
bool operator==( XlibSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator==( XlibSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( dpy == rhs.dpy ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( dpy == rhs.dpy ) &&
|
||||||
( window == rhs.window );
|
( memcmp( &window, &rhs.window, sizeof( Window ) ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( XlibSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( XlibSurfaceCreateInfoKHR const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
|
Loading…
Reference in New Issue
Block a user