From daae0b6194a197c4b119c7ee7efd31b501662bb8 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 15 Sep 2017 01:22:47 +1200 Subject: [PATCH] Add UniqueHandle non-const accessors, ensure all by reference. (#123) * Add UniqueHandle non-const accessors, ensure all by reference. - Add `Type * operator->()` - Fix `Type get() const` to `const Type & get() const` - Add `Type & get()` * Add support for structure pointer chains was missing some generator code. * Update vulkan.hpp with changes. --- VulkanHppGenerator.cpp | 23 +++++++++++++++++++---- vulkan/vulkan.hpp | 19 +++++++++++++++++-- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index a22e6d8..969ed79 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -381,8 +381,8 @@ const std::string structureChainHeader = R"( StructureChain& operator=(StructureChain const &rhs) { - linkAndCopy(rhs); - return this; + linkAndCopy(rhs); + return *this; } template ClassType& get() { return static_cast(*this);} @@ -607,13 +607,28 @@ const std::string uniqueHandleHeader = R"( { return &m_value; } - + + Type * operator->() + { + return &m_value; + } + Type const& operator*() const { return m_value; } - Type get() const + Type & operator*() + { + return m_value; + } + + const Type & get() const + { + return m_value; + } + + Type & get() { return m_value; } diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index a276624..e8928d7 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -361,13 +361,28 @@ namespace vk { return &m_value; } - + + Type * operator->() + { + return &m_value; + } + Type const& operator*() const { return m_value; } - Type get() const + Type & operator*() + { + return m_value; + } + + const Type & get() const + { + return m_value; + } + + Type & get() { return m_value; }