From 07edfc45d6088051246d5eac3b6b1685d586b6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Thu, 28 Nov 2019 16:01:22 +0100 Subject: [PATCH] Introduce default constructors for UniqueHandle, ObjectDestroy, and ObjectFree (#446) --- VulkanHppGenerator.cpp | 31 ++++++++++++++++++++++++++++--- vulkan/vulkan.hpp | 31 ++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index 460b40f..934d7d0 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -4589,7 +4589,13 @@ int main( int argc, char **argv ) class ObjectDestroy { public: - ObjectDestroy( OwnerType owner = OwnerType(), Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT + ObjectDestroy() + : m_owner() + , m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + + ObjectDestroy( OwnerType owner, Optional allocationCallbacks, Dispatch const &dispatch ) VULKAN_HPP_NOEXCEPT : m_owner( owner ) , m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -4602,6 +4608,7 @@ int main( int argc, char **argv ) template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_owner && m_dispatch ); m_owner.destroy( t, m_allocationCallbacks, *m_dispatch ); } @@ -4617,6 +4624,11 @@ int main( int argc, char **argv ) class ObjectDestroy { public: + ObjectDestroy() + : m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + ObjectDestroy( Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT : m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -4628,6 +4640,7 @@ int main( int argc, char **argv ) template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_dispatch ); t.destroy( m_allocationCallbacks, *m_dispatch ); } @@ -4642,7 +4655,13 @@ int main( int argc, char **argv ) class ObjectFree { public: - ObjectFree( OwnerType owner = OwnerType(), Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT + ObjectFree() + : m_owner() + , m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + + ObjectFree( OwnerType owner, Optional allocationCallbacks, Dispatch const &dispatch ) VULKAN_HPP_NOEXCEPT : m_owner( owner ) , m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -4655,6 +4674,7 @@ int main( int argc, char **argv ) template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_owner && m_dispatch ); m_owner.free( t, m_allocationCallbacks, *m_dispatch ); } @@ -4904,7 +4924,12 @@ int main( int argc, char **argv ) public: using element_type = Type; - explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) VULKAN_HPP_NOEXCEPT + UniqueHandle() + : Deleter() + , m_value() + {} + + explicit UniqueHandle( Type const& value, Deleter const& deleter = Deleter() ) VULKAN_HPP_NOEXCEPT : Deleter( deleter) , m_value( value ) {} diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 51e477f..f4d6c46 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -594,7 +594,12 @@ namespace VULKAN_HPP_NAMESPACE public: using element_type = Type; - explicit UniqueHandle( Type const& value = Type(), Deleter const& deleter = Deleter() ) VULKAN_HPP_NOEXCEPT + UniqueHandle() + : Deleter() + , m_value() + {} + + explicit UniqueHandle( Type const& value, Deleter const& deleter = Deleter() ) VULKAN_HPP_NOEXCEPT : Deleter( deleter) , m_value( value ) {} @@ -2646,7 +2651,13 @@ namespace VULKAN_HPP_NAMESPACE class ObjectDestroy { public: - ObjectDestroy( OwnerType owner = OwnerType(), Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT + ObjectDestroy() + : m_owner() + , m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + + ObjectDestroy( OwnerType owner, Optional allocationCallbacks, Dispatch const &dispatch ) VULKAN_HPP_NOEXCEPT : m_owner( owner ) , m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -2659,6 +2670,7 @@ namespace VULKAN_HPP_NAMESPACE template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_owner && m_dispatch ); m_owner.destroy( t, m_allocationCallbacks, *m_dispatch ); } @@ -2674,6 +2686,11 @@ namespace VULKAN_HPP_NAMESPACE class ObjectDestroy { public: + ObjectDestroy() + : m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + ObjectDestroy( Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT : m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -2685,6 +2702,7 @@ namespace VULKAN_HPP_NAMESPACE template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_dispatch ); t.destroy( m_allocationCallbacks, *m_dispatch ); } @@ -2697,7 +2715,13 @@ namespace VULKAN_HPP_NAMESPACE class ObjectFree { public: - ObjectFree( OwnerType owner = OwnerType(), Optional allocationCallbacks = nullptr, Dispatch const &dispatch = VULKAN_HPP_DEFAULT_DISPATCHER ) VULKAN_HPP_NOEXCEPT + ObjectFree() + : m_owner() + , m_allocationCallbacks( nullptr ) + , m_dispatch( nullptr ) + {} + + ObjectFree( OwnerType owner, Optional allocationCallbacks, Dispatch const &dispatch ) VULKAN_HPP_NOEXCEPT : m_owner( owner ) , m_allocationCallbacks( allocationCallbacks ) , m_dispatch( &dispatch ) @@ -2710,6 +2734,7 @@ namespace VULKAN_HPP_NAMESPACE template void destroy(T t) VULKAN_HPP_NOEXCEPT { + assert( m_owner && m_dispatch ); m_owner.free( t, m_allocationCallbacks, *m_dispatch ); }