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";
// ResultValue
auto const hardCodedResultValueTypes = std::array{ "ignore", "ResultValue", "ResultValueType", "createResultValueType" };
for ( auto const & className : hardCodedResultValueTypes )
// some hardcoded types
auto const 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 += replaceWithMap( usingTemplate, { { "className", "resultCheck" } } ) + "\n";
usings += generateConstexprUsings() + "\n";
usings += "\n" + generateConstexprUsings() + "\n";
// structs, handles, UniqueHandles, etc
usings += generateCppModuleStructUsings();
@ -9812,7 +9810,7 @@ std::string VulkanHppGenerator::generateResultCheck(
std::string successCodeList = generateSuccessCodeList( commandData.successCodes, enumerating );
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(
resultCheckTemplate,
@ -9918,12 +9916,12 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
if ( returnVariable.empty() )
{
assert( !unique );
returnStatement = "return createResultValueType( result );";
returnStatement = "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result );";
}
else if ( unique )
{
assert( returnParam != INVALID_INDEX );
returnStatement = "return createResultValueType( result, ";
returnStatement = "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, ";
if ( dataType.starts_with( "std::" ) )
{
returnStatement += "std::move( unique" + startUpperCase( returnVariable ) + " )";
@ -9938,7 +9936,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
}
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>
struct ResultValue
{
@ -107,33 +105,41 @@
#endif
};
VULKAN_HPP_INLINE typename ResultValueType<void>::type createResultValueType( Result result )
namespace detail
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
return result;
#else
ignore( result );
#endif
}
template <typename T>
void ignore( T const & ) VULKAN_HPP_NOEXCEPT
{
}
template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T & data )
{
VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<void>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result )
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, data );
return result;
#else
ignore( result );
return data;
VULKAN_HPP_NAMESPACE::detail::ignore( result );
#endif
}
}
template <typename T>
VULKAN_HPP_INLINE typename ResultValueType<T>::type createResultValueType( Result result, T && data )
{
template <typename T>
VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T & data )
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, std::move( data ) );
return ResultValue<T>( result, data );
#else
ignore( result );
return std::move( data );
VULKAN_HPP_NAMESPACE::detail::ignore( result );
return data;
#endif
}
}
template <typename T>
VULKAN_HPP_INLINE typename VULKAN_HPP_NAMESPACE::ResultValueType<T>::type createResultValueType( VULKAN_HPP_NAMESPACE::Result result, T && data )
{
#ifdef VULKAN_HPP_NO_EXCEPTIONS
return ResultValue<T>( result, std::move( data ) );
#else
VULKAN_HPP_NAMESPACE::detail::ignore( result );
return std::move( data );
#endif
}
} // namespace detail

View File

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

View File

@ -908,11 +908,11 @@ export namespace VULKAN_HPP_NAMESPACE
using VULKAN_HPP_NAMESPACE::InvalidVideoStdParametersKHRError;
#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::ResultValueType;
using VULKAN_HPP_NAMESPACE::detail::createResultValueType;
using VULKAN_HPP_NAMESPACE::detail::ignore;
using VULKAN_HPP_NAMESPACE::detail::resultCheck;
//===========================
//=== CONSTEXPR CONSTANTs ===

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff