Extend support of VULKAN_HPP_NO_EXCEPTIONS in the raii-namespace (#2226)
This commit is contained in:
parent
e6d0135c57
commit
7dfe7d3ad9
|
|
@ -3485,7 +3485,7 @@ std::string VulkanHppGenerator::generateCommandEnhanced( std::string const &
|
|||
std::string typenameCheck = generateTypenameCheck( returnParams, vectorParams, chainedReturnParams, definition, dataTypes, flavourFlags );
|
||||
std::string nodiscard = generateNoDiscard( !returnParams.empty(), 1 < commandData.successCodes.size(), 1 < commandData.errorCodes.size() );
|
||||
std::string returnType = generateReturnType( returnParams, vectorParams, flavourFlags, false, dataTypes );
|
||||
std::string decoratedReturnType = generateDecoratedReturnType( commandData, returnParams, vectorParams, enumerating, flavourFlags, false, returnType );
|
||||
std::string decoratedReturnType = generateDecoratedReturnType( commandData, returnParams, vectorParams, enumerating, flavourFlags, returnType );
|
||||
std::string className = initialSkipCount ? stripPrefix( commandData.params[initialSkipCount - 1].type.type, "Vk" ) : "";
|
||||
std::string classSeparator = commandData.handle.empty() ? "" : "::";
|
||||
std::string commandName = generateCommandName( name, commandData.params, initialSkipCount, flavourFlags );
|
||||
|
|
@ -6606,7 +6606,6 @@ std::string VulkanHppGenerator::generateDecoratedReturnType( CommandData const &
|
|||
std::map<size_t, VectorParamData> const & vectorParams,
|
||||
bool enumerating,
|
||||
CommandFlavourFlags flavourFlags,
|
||||
bool raii,
|
||||
std::string const & returnType ) const
|
||||
{
|
||||
const bool chained = flavourFlags & CommandFlavourFlagBits::chained;
|
||||
|
|
@ -6638,7 +6637,7 @@ std::string VulkanHppGenerator::generateDecoratedReturnType( CommandData const &
|
|||
}
|
||||
}
|
||||
else if ( ( commandData.returnType == "void" ) ||
|
||||
( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && ( commandData.errorCodes.empty() || raii ) ) )
|
||||
( ( commandData.returnType == "VkResult" ) && ( commandData.successCodes.size() == 1 ) && commandData.errorCodes.empty() ) )
|
||||
{
|
||||
assert( !unique );
|
||||
assert( ( commandData.returnType != "void" ) || ( returnParams.size() <= 2 ) );
|
||||
|
|
@ -6651,7 +6650,7 @@ std::string VulkanHppGenerator::generateDecoratedReturnType( CommandData const &
|
|||
if ( ( commandData.successCodes.size() == 1 ) ||
|
||||
( ( commandData.successCodes.size() == 2 ) && ( commandData.successCodes[1] == "VK_INCOMPLETE" ) && enumerating ) )
|
||||
{
|
||||
decoratedReturnType = raii ? returnType : ( "typename ResultValueType<" + returnType + ">::type" );
|
||||
decoratedReturnType = "typename ResultValueType<" + returnType + ">::type";
|
||||
}
|
||||
else if ( !commandData.errorCodes.empty() && ( 1 < commandData.successCodes.size() ) &&
|
||||
( ( returnParams.size() == 1 ) ||
|
||||
|
|
@ -6659,7 +6658,7 @@ std::string VulkanHppGenerator::generateDecoratedReturnType( CommandData const &
|
|||
( commandData.successCodes[1] == "VK_INCOMPLETE" ) ) ) ) ||
|
||||
( ( returnParams.size() == 3 ) && vectorParams.empty() ) ) )
|
||||
{
|
||||
decoratedReturnType = ( raii ? "std::pair<Result, " : "ResultValue<" ) + returnType + ">";
|
||||
decoratedReturnType = "ResultValue<" + returnType + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -8945,33 +8944,36 @@ ${deviceMembers}
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::generateRAIIFactoryReturnStatements( std::vector<ParamData> const & params,
|
||||
std::vector<std::string> const & successCodes,
|
||||
std::string const & vkType,
|
||||
bool enumerating,
|
||||
std::string const & returnType,
|
||||
std::string const & returnVariable,
|
||||
bool singular ) const
|
||||
std::string VulkanHppGenerator::generateRAIIFactoryReturnStatements( CommandData const & commandData,
|
||||
std::string const & vkType,
|
||||
bool enumerating,
|
||||
std::string const & returnType,
|
||||
std::string const & returnVariable,
|
||||
bool singular ) const
|
||||
{
|
||||
auto handleIt = findByNameOrAlias( m_handles, vkType );
|
||||
assert( handleIt != m_handles.end() );
|
||||
|
||||
std::string successCodePassToElement = ( enumerating ? ( successCodes.size() <= 2 ) : ( successCodes.size() <= 1 ) ) ? "" : ", result";
|
||||
std::string successCodePassToElement =
|
||||
( enumerating ? ( commandData.successCodes.size() <= 2 ) : ( commandData.successCodes.size() <= 1 ) ) ? "" : ", result";
|
||||
if ( returnType.starts_with( "std::vector" ) )
|
||||
{
|
||||
assert( !successCodes.empty() );
|
||||
assert( !commandData.successCodes.empty() );
|
||||
|
||||
std::string const & returnTemplate = R"(${returnType} ${returnVariable}RAII;
|
||||
${returnVariable}RAII.reserve( ${returnVariable}.size() );
|
||||
for ( auto & ${element} : ${returnVariable} )
|
||||
if ( result == Result::eSuccess )
|
||||
{
|
||||
${returnVariable}RAII.emplace_back( *this, ${handleConstructorArguments}${successCodePassToElement} );
|
||||
${returnVariable}RAII.reserve( ${returnVariable}.size() );
|
||||
for ( auto & ${element} : ${returnVariable} )
|
||||
{
|
||||
${returnVariable}RAII.emplace_back( *this, ${handleConstructorArguments}${successCodePassToElement} );
|
||||
}
|
||||
}
|
||||
return ${returnVariable}RAII;
|
||||
return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, std::move( ${returnVariable}RAII ) );
|
||||
)";
|
||||
|
||||
std::string element = stripPluralS( returnVariable );
|
||||
std::string handleConstructorArguments = generateRAIIHandleSingularConstructorArguments( *handleIt, params, vkType, element );
|
||||
std::string handleConstructorArguments = generateRAIIHandleSingularConstructorArguments( *handleIt, commandData.params, vkType, element );
|
||||
|
||||
return replaceWithMap( returnTemplate,
|
||||
{ { "element", element },
|
||||
|
|
@ -8982,15 +8984,24 @@ std::string VulkanHppGenerator::generateRAIIFactoryReturnStatements( std::vector
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string const & returnTemplate = "return ${returnType}( *this, ${handleConstructorArguments}${successCodePassToElement} );";
|
||||
std::string const & returnTypeTemplate = "${returnType}( *this, ${handleConstructorArguments}${successCodePassToElement} )";
|
||||
|
||||
std::string handleConstructorArguments =
|
||||
generateRAIIHandleSingularConstructorArguments( *handleIt, params, vkType, singular ? stripPluralS( returnVariable ) : returnVariable );
|
||||
generateRAIIHandleSingularConstructorArguments( *handleIt, commandData.params, vkType, singular ? stripPluralS( returnVariable ) : returnVariable );
|
||||
|
||||
return replaceWithMap( returnTemplate,
|
||||
{ { "returnType", returnType },
|
||||
{ "handleConstructorArguments", handleConstructorArguments },
|
||||
{ "successCodePassToElement", successCodePassToElement } } );
|
||||
std::string constructorCall = replaceWithMap( returnTypeTemplate,
|
||||
{ { "returnType", returnType },
|
||||
{ "handleConstructorArguments", handleConstructorArguments },
|
||||
{ "successCodePassToElement", successCodePassToElement } } );
|
||||
|
||||
if ( commandData.successCodes.empty() && commandData.errorCodes.empty() )
|
||||
{
|
||||
return "return " + constructorCall + ";";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "return VULKAN_HPP_NAMESPACE::detail::createResultValueType( result, " + constructorCall + " );";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9363,7 +9374,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandEnhanced( std::string c
|
|||
needsVectorSizeCheck( commandData.params, vectorParams, returnParams, singularParams, skippedParams );
|
||||
std::string noexceptString = generateNoExcept( commandData.errorCodes, returnParams, vectorParams, flavourFlags, vectorSizeCheck.first, true );
|
||||
std::string returnType = generateReturnType( returnParams, vectorParams, flavourFlags, true, dataTypes );
|
||||
std::string decoratedReturnType = generateDecoratedReturnType( commandData, returnParams, vectorParams, enumerating, flavourFlags, true, returnType );
|
||||
std::string decoratedReturnType = generateDecoratedReturnType( commandData, returnParams, vectorParams, enumerating, flavourFlags, returnType );
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
|
|
@ -9487,7 +9498,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
|
|||
}
|
||||
|
||||
handleType = stripPrefix( handleType, "Vk" );
|
||||
std::string noexceptString = enumerating ? "" : "VULKAN_HPP_RAII_CREATE_NOEXCEPT";
|
||||
std::string noexceptString = enumerating ? "" : "VULKAN_HPP_NOEXCEPT_WHEN_NO_EXCEPTIONS";
|
||||
std::string returnType = handleType;
|
||||
if ( vectorParams.contains( returnParams.back() ) && !singular )
|
||||
{
|
||||
|
|
@ -9495,6 +9506,11 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
|
|||
returnType = "std::vector<" + handleType + ">";
|
||||
handleType += "s";
|
||||
}
|
||||
std::string decoratedReturnType = returnType;
|
||||
if (!commandData.errorCodes.empty())
|
||||
{
|
||||
decoratedReturnType = "typename ResultValueType<" + returnType + ">::type";
|
||||
}
|
||||
|
||||
if ( definition )
|
||||
{
|
||||
|
|
@ -9517,14 +9533,13 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
|
|||
generateDataDeclarations( commandData, returnParams, vectorParams, {}, flavourFlags, true, dataTypes, dataType, returnType, returnVariable );
|
||||
std::string callSequence =
|
||||
generateCallSequence( name, commandData, returnParams, vectorParams, initialSkipCount, singularParams, {}, {}, flavourFlags, true, true );
|
||||
std::string resultCheck = generateResultCheckExpected( commandData.successCodes, className, commandName );
|
||||
std::string returnStatements =
|
||||
generateRAIIFactoryReturnStatements( commandData.params, commandData.successCodes, vulkanType, enumerating, returnType, returnVariable, singular );
|
||||
std::string resultCheck = generateResultCheck( commandData, className, "::", commandName, enumerating, true );
|
||||
std::string returnStatements = generateRAIIFactoryReturnStatements( commandData, vulkanType, enumerating, returnType, returnVariable, singular );
|
||||
|
||||
std::string const definitionTemplate =
|
||||
R"(
|
||||
// wrapper function for command ${vkCommandName}, see https://registry.khronos.org/vulkan/specs/latest/man/html/${vkCommandName}.html
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE detail::CreateReturnType<${returnType}>::Type ${className}::${commandName}( ${argumentList} ) const ${noexcept}
|
||||
VULKAN_HPP_NODISCARD VULKAN_HPP_INLINE ${returnType} ${className}::${commandName}( ${argumentList} ) const ${noexcept}
|
||||
{
|
||||
${dataDeclarations}
|
||||
${callSequence}
|
||||
|
|
@ -9542,7 +9557,7 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
|
|||
{ "noexcept", noexceptString },
|
||||
{ "resultCheck", resultCheck },
|
||||
{ "returnStatements", returnStatements },
|
||||
{ "returnType", returnType },
|
||||
{ "returnType", decoratedReturnType },
|
||||
{ "vkCommandName", name } } );
|
||||
}
|
||||
else
|
||||
|
|
@ -9550,14 +9565,14 @@ std::string VulkanHppGenerator::generateRAIIHandleCommandFactory( std::string co
|
|||
std::string const declarationTemplate =
|
||||
R"(
|
||||
// wrapper function for command ${vkCommandName}, see https://registry.khronos.org/vulkan/specs/latest/man/html/${vkCommandName}.html
|
||||
VULKAN_HPP_NODISCARD detail::CreateReturnType<${returnType}>::Type ${commandName}( ${argumentList} ) const ${noexcept};
|
||||
VULKAN_HPP_NODISCARD ${returnType} ${commandName}( ${argumentList} ) const ${noexcept};
|
||||
)";
|
||||
|
||||
return replaceWithMap( declarationTemplate,
|
||||
{ { "argumentList", argumentList },
|
||||
{ "commandName", commandName },
|
||||
{ "noexcept", noexceptString },
|
||||
{ "returnType", returnType },
|
||||
{ "returnType", decoratedReturnType },
|
||||
{ "vkCommandName", name } } );
|
||||
}
|
||||
}
|
||||
|
|
@ -10128,7 +10143,7 @@ std::string VulkanHppGenerator::generateRAIIHandleConstructorByCall( std::pair<s
|
|||
|
||||
const std::string constructorTemplate =
|
||||
R"(
|
||||
#if !defined( VULKAN_HPP_RAII_NO_EXCEPTIONS )
|
||||
#if !defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
${enter} ${handleType}${plural}( ${constructorArguments} )
|
||||
{
|
||||
*this = ${parentName}.${createCall}( ${createArguments} );
|
||||
|
|
@ -10711,50 +10726,19 @@ std::string VulkanHppGenerator::generateResultCheck( CommandData const & command
|
|||
std::string successCodeList = generateSuccessCodeList( commandData.successCodes, enumerating );
|
||||
|
||||
std::string const resultCheckTemplate =
|
||||
R"(${namespace}detail::resultCheck( result, VULKAN_HPP_NAMESPACE_STRING "::${className}${classSeparator}${commandName}"${successCodeList} );)";
|
||||
R"(${namespace}detail::resultCheck( result, ${namespaceString} "::${className}${classSeparator}${commandName}"${successCodeList} );)";
|
||||
|
||||
resultCheck = replaceWithMap( resultCheckTemplate,
|
||||
{ { "className", className },
|
||||
{ "classSeparator", classSeparator },
|
||||
{ "commandName", commandName },
|
||||
{ "namespace", raii ? "VULKAN_HPP_NAMESPACE::" : "" },
|
||||
{ "namespaceString", raii ? "VULKAN_HPP_RAII_NAMESPACE_STRING" : "VULKAN_HPP_NAMESPACE_STRING" },
|
||||
{ "successCodeList", successCodeList } } );
|
||||
}
|
||||
return resultCheck;
|
||||
}
|
||||
|
||||
std::string VulkanHppGenerator::generateResultCheckExpected( std::vector<std::string> const & successCodes,
|
||||
std::string const & className,
|
||||
std::string const & commandName ) const
|
||||
{
|
||||
std::string resultCheck;
|
||||
if ( !successCodes.empty() )
|
||||
{
|
||||
std::string condition = "result != " + generateSuccessCode( successCodes[0] );
|
||||
if ( 1 < successCodes.size() )
|
||||
{
|
||||
condition = "( " + condition + " )";
|
||||
for ( size_t i = 1; i < successCodes.size(); ++i )
|
||||
{
|
||||
condition += " && ( result != " + generateSuccessCode( successCodes[i] ) + " )";
|
||||
}
|
||||
}
|
||||
|
||||
std::string const resultCheckTemplate = R"(if ( ${condition} )
|
||||
{
|
||||
#if defined( VULKAN_HPP_RAII_NO_EXCEPTIONS )
|
||||
return VULKAN_HPP_UNEXPECTED( result );
|
||||
#else
|
||||
VULKAN_HPP_NAMESPACE::detail::throwResultException( result, "${className}::${commandName}" );
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
resultCheck = replaceWithMap( resultCheckTemplate, { { "className", className }, { "commandName", commandName }, { "condition", condition } } );
|
||||
}
|
||||
return resultCheck;
|
||||
}
|
||||
|
||||
// Intended only for `enum class Result`!
|
||||
std::string VulkanHppGenerator::generateResultExceptions() const
|
||||
{
|
||||
|
|
@ -10808,7 +10792,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||
if ( ( commandData.successCodes.size() == 1 ) || ( enumerating && ( commandData.successCodes.size() == 2 ) ) )
|
||||
{
|
||||
assert( commandData.successCodes[0] == "VK_SUCCESS" );
|
||||
if ( raii || commandData.errorCodes.empty() )
|
||||
if ( commandData.errorCodes.empty() )
|
||||
{
|
||||
if ( !returnVariable.empty() )
|
||||
{
|
||||
|
|
@ -10817,15 +10801,16 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||
}
|
||||
else
|
||||
{
|
||||
returnStatement = "return "s + ( raii ? "VULKAN_HPP_NAMESPACE::" : "" ) + "detail::createResultValueType( ";
|
||||
if ( returnVariable.empty() )
|
||||
{
|
||||
assert( !unique );
|
||||
returnStatement = "return detail::createResultValueType( result );";
|
||||
returnStatement += "result );";
|
||||
}
|
||||
else if ( unique )
|
||||
{
|
||||
assert( returnParam != INVALID_INDEX );
|
||||
returnStatement = "return detail::createResultValueType( result, ";
|
||||
returnStatement += "result, ";
|
||||
if ( dataType.starts_with( "std::" ) )
|
||||
{
|
||||
returnStatement += "std::move( unique" + startUpperCase( returnVariable ) + " )";
|
||||
|
|
@ -10843,7 +10828,7 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||
}
|
||||
else
|
||||
{
|
||||
returnStatement = "return detail::createResultValueType( result, std::move( " + returnVariable + " ) );";
|
||||
returnStatement += "result, std::move( " + returnVariable + " ) );";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10872,8 +10857,8 @@ std::string VulkanHppGenerator::generateReturnStatement( std::string const & com
|
|||
}
|
||||
else
|
||||
{
|
||||
assert( decoratedReturnType.starts_with( raii ? "std::pair<Result, " : "ResultValue<" ) && decoratedReturnType.ends_with( ">" ) );
|
||||
returnStatement = "return " + ( raii ? "std::make_pair" : decoratedReturnType ) + "( result, std::move( " + returnVariable + " ) );";
|
||||
assert( decoratedReturnType.starts_with( "ResultValue<" ) && decoratedReturnType.ends_with( ">" ) );
|
||||
returnStatement = "return " + decoratedReturnType + "( result, std::move( " + returnVariable + " ) );";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -851,7 +851,6 @@ private:
|
|||
std::map<size_t, VectorParamData> const & vectorParams,
|
||||
bool enumerating,
|
||||
CommandFlavourFlags flavourFlags,
|
||||
bool raii,
|
||||
std::string const & returnType ) const;
|
||||
std::string generateDeprecatedConstructors( std::string const & name ) const;
|
||||
std::string generateDeprecatedStructSetters( std::string const & name ) const;
|
||||
|
|
@ -926,13 +925,12 @@ private:
|
|||
std::string
|
||||
generateRAIICommandDefinitions( std::vector<RequireData> const & requireData, std::set<std::string> & listedCommands, std::string const & title ) const;
|
||||
std::string generateRAIIDispatchers() const;
|
||||
std::string generateRAIIFactoryReturnStatements( std::vector<ParamData> const & params,
|
||||
std::vector<std::string> const & successCodes,
|
||||
std::string const & vkType,
|
||||
bool enumerating,
|
||||
std::string const & returnType,
|
||||
std::string const & returnVariable,
|
||||
bool singular ) const;
|
||||
std::string generateRAIIFactoryReturnStatements( CommandData const & commandData,
|
||||
std::string const & vkType,
|
||||
bool enumerating,
|
||||
std::string const & returnType,
|
||||
std::string const & returnVariable,
|
||||
bool singular ) const;
|
||||
std::string generateRAIIHandle( std::pair<std::string, HandleData> const & handle,
|
||||
std::set<std::string> & listedHandles,
|
||||
std::set<std::string> const & specialFunctions ) const;
|
||||
|
|
@ -1013,8 +1011,6 @@ private:
|
|||
std::string commandName,
|
||||
bool enumerating,
|
||||
bool raii ) const;
|
||||
std::string
|
||||
generateResultCheckExpected( std::vector<std::string> const & successCodes, std::string const & className, std::string const & commandName ) const;
|
||||
std::string generateResultExceptions() const;
|
||||
std::string generateReturnStatement( std::string const & commandName,
|
||||
CommandData const & commandData,
|
||||
|
|
|
|||
|
|
@ -15,17 +15,6 @@ namespace VULKAN_HPP_NAMESPACE
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
template <class T>
|
||||
class CreateReturnType
|
||||
{
|
||||
public:
|
||||
#if defined( VULKAN_HPP_RAII_NO_EXCEPTIONS )
|
||||
using Type = VULKAN_HPP_EXPECTED<T, Result>;
|
||||
#else
|
||||
using Type = T;
|
||||
#endif
|
||||
};
|
||||
|
||||
using PFN_dummy = void ( * )();
|
||||
|
||||
${RAIIDispatchers}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,40 @@
|
|||
Result result;
|
||||
T value;
|
||||
|
||||
operator std::tuple<Result&, T&>() VULKAN_HPP_NOEXCEPT { return std::tuple<Result&, T&>(result, value); }
|
||||
operator std::tuple<Result &, T &>() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return std::tuple<Result &, T &>( result, value );
|
||||
}
|
||||
|
||||
// std::expected-look alike
|
||||
bool has_value() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return result == vk::Result::eSuccess;
|
||||
}
|
||||
|
||||
T const * operator->() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return &value;
|
||||
}
|
||||
|
||||
T * operator->() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return &value;
|
||||
}
|
||||
|
||||
T const & operator*() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert(has_value ());
|
||||
return value;
|
||||
}
|
||||
|
||||
T & operator*() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert(has_value ());
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined( VULKAN_HPP_NO_SMART_HANDLE )
|
||||
|
|
|
|||
|
|
@ -287,21 +287,7 @@ namespace VULKAN_HPP_NAMESPACE
|
|||
# define VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT = VULKAN_HPP_DEFAULT_DISPATCHER
|
||||
#endif
|
||||
|
||||
#if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected )
|
||||
# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) )
|
||||
# include <expected>
|
||||
# endif
|
||||
# define VULKAN_HPP_EXPECTED std::expected
|
||||
# define VULKAN_HPP_UNEXPECTED std::unexpected
|
||||
#endif
|
||||
|
||||
#if !defined( VULKAN_HPP_RAII_NAMESPACE )
|
||||
# define VULKAN_HPP_RAII_NAMESPACE raii
|
||||
#endif
|
||||
|
||||
#if defined( VULKAN_HPP_NO_EXCEPTIONS ) && defined( VULKAN_HPP_EXPECTED )
|
||||
# define VULKAN_HPP_RAII_NO_EXCEPTIONS
|
||||
# define VULKAN_HPP_RAII_CREATE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define VULKAN_HPP_RAII_CREATE_NOEXCEPT
|
||||
# define VULKAN_HPP_RAII_NAMESPACE_STRING VULKAN_HPP_STRINGIFY( VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE )
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
vulkan_hpp__setup_test( NAME NoExceptionsRAII LIBRARIES utils CXX_STANDARD 23)
|
||||
vulkan_hpp__setup_test( NAME NoExceptionsRAII LIBRARIES utils)
|
||||
|
||||
if( UNIX )
|
||||
target_link_libraries( NoExceptionsRAII PRIVATE ${CMAKE_DL_LIBS} )
|
||||
|
|
|
|||
|
|
@ -18,20 +18,14 @@
|
|||
|
||||
#define VULKAN_HPP_NO_EXCEPTIONS
|
||||
|
||||
// for this test, we need to include vulkan_hpp_macros.hpp first to determine if VULKAN_HPP_RAII_NO_EXCEPTIONS is defined in this context
|
||||
#include <vulkan/vulkan_hpp_macros.hpp>
|
||||
|
||||
// only if VULKAN_HPP_RAII_NO_EXCEPTIONS really is defined, this test is meaningfull and needs to compile and run.
|
||||
#if defined( VULKAN_HPP_RAII_NO_EXCEPTIONS )
|
||||
# include <vulkan/vulkan_raii.hpp>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
static char const * AppName = "NoExceptions";
|
||||
static char const * EngineName = "Vulkan.hpp";
|
||||
#endif
|
||||
|
||||
int main( int /*argc*/, char ** /*argv*/ )
|
||||
{
|
||||
#if defined( VULKAN_HPP_RAII_NO_EXCEPTIONS )
|
||||
#if defined( VULKAN_HPP_NO_EXCEPTIONS )
|
||||
vk::raii::Context context;
|
||||
|
||||
vk::ApplicationInfo appInfo( AppName, 1, EngineName, 1, VK_API_VERSION_1_1 );
|
||||
|
|
@ -40,7 +34,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
|||
|
||||
auto physicalDevices = instance->enumeratePhysicalDevices();
|
||||
assert( physicalDevices.has_value() );
|
||||
auto physicalDevice = std::move( physicalDevices->front() );
|
||||
auto physicalDevice = physicalDevices->front();
|
||||
|
||||
// get the QueueFamilyProperties of the first PhysicalDevice
|
||||
std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevice.getQueueFamilyProperties();
|
||||
|
|
@ -67,7 +61,7 @@ int main( int /*argc*/, char ** /*argv*/ )
|
|||
auto commandBuffers = device->allocateCommandBuffers( vk::CommandBufferAllocateInfo( *commandPool, vk::CommandBufferLevel::ePrimary, 1 ) );
|
||||
assert( commandBuffers.has_value() );
|
||||
|
||||
auto commandBuffer = std::move( commandBuffers->front() );
|
||||
auto commandBuffer = std::move( commandBuffers.value[0] );
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -7243,6 +7243,36 @@ namespace VULKAN_HPP_NAMESPACE
|
|||
{
|
||||
return std::tuple<Result &, T &>( result, value );
|
||||
}
|
||||
|
||||
// std::expected-look alike
|
||||
bool has_value() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
return result == vk::Result::eSuccess;
|
||||
}
|
||||
|
||||
T const * operator->() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return &value;
|
||||
}
|
||||
|
||||
T * operator->() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return &value;
|
||||
}
|
||||
|
||||
T const & operator*() const VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return value;
|
||||
}
|
||||
|
||||
T & operator*() VULKAN_HPP_NOEXCEPT
|
||||
{
|
||||
assert( has_value() );
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined( VULKAN_HPP_NO_SMART_HANDLE )
|
||||
|
|
|
|||
|
|
@ -304,23 +304,9 @@ namespace VULKAN_HPP_NAMESPACE
|
|||
# define VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT = VULKAN_HPP_DEFAULT_DISPATCHER
|
||||
#endif
|
||||
|
||||
#if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected )
|
||||
# if !( defined( VULKAN_HPP_ENABLE_STD_MODULE ) && defined( VULKAN_HPP_STD_MODULE ) )
|
||||
# include <expected>
|
||||
# endif
|
||||
# define VULKAN_HPP_EXPECTED std::expected
|
||||
# define VULKAN_HPP_UNEXPECTED std::unexpected
|
||||
#endif
|
||||
|
||||
#if !defined( VULKAN_HPP_RAII_NAMESPACE )
|
||||
# define VULKAN_HPP_RAII_NAMESPACE raii
|
||||
#endif
|
||||
|
||||
#if defined( VULKAN_HPP_NO_EXCEPTIONS ) && defined( VULKAN_HPP_EXPECTED )
|
||||
# define VULKAN_HPP_RAII_NO_EXCEPTIONS
|
||||
# define VULKAN_HPP_RAII_CREATE_NOEXCEPT noexcept
|
||||
#else
|
||||
# define VULKAN_HPP_RAII_CREATE_NOEXCEPT
|
||||
# define VULKAN_HPP_RAII_NAMESPACE raii
|
||||
# define VULKAN_HPP_RAII_NAMESPACE_STRING VULKAN_HPP_STRINGIFY( VULKAN_HPP_NAMESPACE::VULKAN_HPP_RAII_NAMESPACE )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue