Moved some implementation details into namespace detail. (#1840)

This commit is contained in:
Andreas Süßenbach 2024-04-08 11:40:53 +02:00 committed by GitHub
parent 4e9c7ec4c3
commit bb66ad3b04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 1329 additions and 1310 deletions

View File

@ -5669,17 +5669,15 @@ std::string VulkanHppGenerator::generateCppModuleUsings() const
usings += exceptionsLeave + "\n"; usings += exceptionsLeave + "\n";
// ResultValue // some hardcoded types
auto const hardCodedResultValueTypes = std::array{ "ignore", "ResultValue", "ResultValueType", "createResultValueType" }; auto const hardCodedResultValueTypes =
for ( auto const & className : hardCodedResultValueTypes ) std::array{ "ResultValue", "ResultValueType", "detail::createResultValueType", "detail::ignore", "detail::resultCheck" };
for ( auto const & valueType : hardCodedResultValueTypes )
{ {
usings += replaceWithMap( usingTemplate, { { "className", className } } ); usings += replaceWithMap( usingTemplate, { { "className", valueType } } );
} }
// resultCheck usings += "\n" + generateConstexprUsings() + "\n";
usings += replaceWithMap( usingTemplate, { { "className", "resultCheck" } } ) + "\n";
usings += generateConstexprUsings() + "\n";
// structs, handles, UniqueHandles, etc // structs, handles, UniqueHandles, etc
usings += generateCppModuleStructUsings(); usings += generateCppModuleStructUsings();
@ -9812,7 +9810,7 @@ std::string VulkanHppGenerator::generateResultCheck(
std::string successCodeList = generateSuccessCodeList( commandData.successCodes, enumerating ); std::string successCodeList = generateSuccessCodeList( commandData.successCodes, enumerating );
std::string const resultCheckTemplate = std::string const resultCheckTemplate =
R"(resultCheck( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );)"; R"(VULKAN_HPP_NAMESPACE::detail::resultCheck( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );)";
resultCheck = replaceWithMap( resultCheck = replaceWithMap(
resultCheckTemplate, resultCheckTemplate,
@ -9918,12 +9916,12 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
if ( returnVariable.empty() ) if ( returnVariable.empty() )
{ {
assert( !unique ); assert( !unique );
returnStatement = "return createResultValueType( result );"; returnStatement = "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result );";
} }
else if ( unique ) else if ( unique )
{ {
assert( returnParam != INVALID_INDEX ); assert( returnParam != INVALID_INDEX );
returnStatement = "return createResultValueType( result, "; returnStatement = "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, ";
if ( dataType.starts_with( "std::" ) ) if ( dataType.starts_with( "std::" ) )
{ {
returnStatement += "std::move( unique" + startUpperCase( returnVariable ) + " )"; returnStatement += "std::move( unique" + startUpperCase( returnVariable ) + " )";
@ -9938,7 +9936,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
} }
else else
{ {
returnStatement = "return createResultValueType( result, std::move( " + returnVariable + " ) );"; returnStatement = "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, std::move( " + returnVariable + " ) );";
} }
} }
} }

View File

@ -1,5 +1,3 @@
template <typename T> void ignore(T const &) VULKAN_HPP_NOEXCEPT {}
template <typename T> template <typename T>
struct ResultValue struct ResultValue
{ {
@ -107,33 +105,41 @@
#endif #endif
}; };
VULKAN_HPP_INLINE typename ResultValueType<void>::type createResultValueType( Result result ) namespace detail
{
template <typename T>
void ignore( T const & ) VULKAN_HPP_NOEXCEPT
{
}
VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<void>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return result; return result;
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
#endif #endif
} }
template <typename T> template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T & data ) VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T & data )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, data ); return ResultValue<T>( result, data );
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
return data; return data;
#endif #endif
} }
template <typename T> template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T && data ) VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T && data )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, std::move( data ) ); return ResultValue<T>( result, std::move( data ) );
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
return std::move( data ); return std::move( data );
#endif #endif
} }
} // namespace detail

View File

@ -1,13 +1,16 @@
namespace detail
{
VULKAN_HPP_INLINE void resultCheck( Result result, char const * message ) VULKAN_HPP_INLINE void resultCheck( Result result, char const * message )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message ); VULKAN_HPP_NAMESPACE::detail::ignore( message );
VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess );
#else #else
if ( result != Result::eSuccess ) if ( result != Result::eSuccess )
{ {
detail::throwResultException( result, message ); VULKAN_HPP_NAMESPACE::detail::throwResultException( result, message );
} }
#endif #endif
} }
@ -15,14 +18,15 @@
VULKAN_HPP_INLINE void resultCheck( Result result, char const * message, std::initializer_list<Result> successCodes ) VULKAN_HPP_INLINE void resultCheck( Result result, char const * message, std::initializer_list<Result> successCodes )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message ); VULKAN_HPP_NAMESPACE::detail::ignore( message );
ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() );
#else #else
if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )
{ {
detail::throwResultException( result, message ); VULKAN_HPP_NAMESPACE::detail::throwResultException( result, message );
} }
#endif #endif
} }
} // namespace detail

View File

@ -908,11 +908,11 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::InvalidVideoStdParametersKHRError; using VULKAN_HPP_NAMESPACE::InvalidVideoStdParametersKHRError;
#endif /*VULKAN_HPP_NO_EXCEPTIONS*/ #endif /*VULKAN_HPP_NO_EXCEPTIONS*/
using VULKAN_HPP_NAMESPACE::createResultValueType;
using VULKAN_HPP_NAMESPACE::ignore;
using VULKAN_HPP_NAMESPACE::resultCheck;
using VULKAN_HPP_NAMESPACE::ResultValue; using VULKAN_HPP_NAMESPACE::ResultValue;
using VULKAN_HPP_NAMESPACE::ResultValueType; using VULKAN_HPP_NAMESPACE::ResultValueType;
using VULKAN_HPP_NAMESPACE::detail::createResultValueType;
using VULKAN_HPP_NAMESPACE::detail::ignore;
using VULKAN_HPP_NAMESPACE::detail::resultCheck;
//=========================== //===========================
//=== CONSTEXPR CONSTANTs === //=== CONSTEXPR CONSTANTs ===

View File

@ -6601,11 +6601,6 @@ namespace VULKAN_HPP_NAMESPACE
} // namespace detail } // namespace detail
#endif #endif
template <typename T>
void ignore( T const & ) VULKAN_HPP_NOEXCEPT
{
}
template <typename T> template <typename T>
struct ResultValue struct ResultValue
{ {
@ -6718,47 +6713,57 @@ namespace VULKAN_HPP_NAMESPACE
#endif #endif
}; };
VULKAN_HPP_INLINE typename ResultValueType<void>::type createResultValueType( Result result ) namespace detail
{
template <typename T>
void ignore( T const & ) VULKAN_HPP_NOEXCEPT
{
}
VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<void>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return result; return result;
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
#endif #endif
} }
template <typename T> template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T & data ) VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T & data )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, data ); return ResultValue<T>( result, data );
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
return data; return data;
#endif #endif
} }
template <typename T> template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T && data ) VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T && data )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, std::move( data ) ); return ResultValue<T>( result, std::move( data ) );
#else #else
ignore( result ); VULKAN_HPP_NAMESPACE::detail::ignore( result );
return std::move( data ); return std::move( data );
#endif #endif
} }
} // namespace detail
namespace detail
{
VULKAN_HPP_INLINE void resultCheck( Result result, char const * message ) VULKAN_HPP_INLINE void resultCheck( Result result, char const * message )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message ); VULKAN_HPP_NAMESPACE::detail::ignore( message );
VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess ); VULKAN_HPP_ASSERT_ON_RESULT( result == Result::eSuccess );
#else #else
if ( result != Result::eSuccess ) if ( result != Result::eSuccess )
{ {
detail::throwResultException( result, message ); VULKAN_HPP_NAMESPACE::detail::throwResultException( result, message );
} }
#endif #endif
} }
@ -6766,17 +6771,18 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_INLINE void resultCheck( Result result, char const * message, std::initializer_list<Result> successCodes ) VULKAN_HPP_INLINE void resultCheck( Result result, char const * message, std::initializer_list<Result> successCodes )
{ {
#ifdef VULKAN_HPP_NO_EXCEPTIONS #ifdef VULKAN_HPP_NO_EXCEPTIONS
ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( result ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
ignore( message ); VULKAN_HPP_NAMESPACE::detail::ignore( message );
ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty VULKAN_HPP_NAMESPACE::detail::ignore( successCodes ); // just in case VULKAN_HPP_ASSERT_ON_RESULT is empty
VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() ); VULKAN_HPP_ASSERT_ON_RESULT( std::find( successCodes.begin(), successCodes.end(), result ) != successCodes.end() );
#else #else
if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() ) if ( std::find( successCodes.begin(), successCodes.end(), result ) == successCodes.end() )
{ {
detail::throwResultException( result, message ); VULKAN_HPP_NAMESPACE::detail::throwResultException( result, message );
} }
#endif #endif
} }
} // namespace detail
//=========================== //===========================
//=== CONSTEXPR CONSTANTs === //=== CONSTEXPR CONSTANTs ===

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff