Skip to content

Commit

Permalink
Snippets and generator changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadhr committed Jul 23, 2024
1 parent 52ed260 commit 8f253dc
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 24 deletions.
42 changes: 31 additions & 11 deletions VulkanHppGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ void VulkanHppGenerator::generateExtensionInspectionFile() const
#ifndef VULKAN_EXTENSION_INSPECTION_HPP
# define VULKAN_EXTENSION_INSPECTION_HPP

#include <map>
#include <set>
#include <string>
#include <vector>
#include <vulkan/${api}.hpp>
#if !defined( VULKAN_HPP_STD_MODULE )
# include <map>
# include <set>
# include <string>
# include <vector>
# include <vulkan/${api}.hpp>
#endif

namespace VULKAN_HPP_NAMESPACE
{
Expand Down Expand Up @@ -583,8 +585,10 @@ void VulkanHppGenerator::generateRAIIHppFile() const
#ifndef VULKAN_RAII_HPP
#define VULKAN_RAII_HPP

#include <memory> // std::unique_ptr
#include <utility> // std::forward
#if !defined( VULKAN_HPP_STD_MODULE )
# include <memory> // std::unique_ptr
# include <utility> // std::forward
#endif
#include <vulkan/${api}.hpp>

#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE )
Expand Down Expand Up @@ -659,8 +663,10 @@ void VulkanHppGenerator::generateSharedHppFile() const
#define VULKAN_SHARED_HPP

#include <vulkan/${api}.hpp>
#include <atomic> // std::atomic_size_t

#if !defined( VULKAN_HPP_STD_MODULE )
#include <atomic> // std::atomic_size_t
#endif

namespace VULKAN_HPP_NAMESPACE
{
Expand Down Expand Up @@ -748,10 +754,15 @@ void VulkanHppGenerator::generateToStringHppFile() const

#include <vulkan/${api}_enums.hpp>

#if __cpp_lib_format
# include <format> // std::format
#if !defined( VULKAN_HPP_STD_MODULE )
# if __cpp_lib_format
# include <format> // std::format
# else
# include <sstream> // std::stringstream
# endif
#else
# include <sstream> // std::stringstream
import VULKAN_HPP_STD_MODULE;
import VULKAN_HPP_STD_COMPAT_MODULE;
#endif

namespace VULKAN_HPP_NAMESPACE
Expand Down Expand Up @@ -783,6 +794,15 @@ void VulkanHppGenerator::generateCppModuleFile() const

module;

// clang-format off
#include <vulkan/vulkan_hpp_macros.hpp>
// clang-format on

#if defined( VULKAN_HPP_STD_MODULE )
import VULKAN_HPP_STD_MODULE;
import VULKAN_HPP_STD_COMPAT_MODULE;
#endif

#include <vulkan/${api}.hpp>
#include <vulkan/${api}_extension_inspection.hpp>
#include <vulkan/${api}_format_traits.hpp>
Expand Down
25 changes: 14 additions & 11 deletions snippets/includes.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#include <algorithm>
#include <array> // ArrayWrapperND
#include <string.h> // strnlen
#include <string> // std::string
#include <utility> // std::exchange
#include <vulkan/${vulkan_h}>
#include <vulkan/vulkan_hpp_macros.hpp>

#if 17 <= VULKAN_HPP_CPP_VERSION
#if !defined( VULKAN_HPP_STD_MODULE )
# include <algorithm>
# include <array> // ArrayWrapperND
# include <string.h> // strnlen
# include <string> // std::string
# include <utility> // std::exchange
#endif
#include <vulkan/${vulkan_h}>

#if 17 <= VULKAN_HPP_CPP_VERSION && !defined( VULKAN_HPP_STD_MODULE )
# include <string_view>
#endif

#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE )
#if !defined( VULKAN_HPP_DISABLE_ENHANCED_MODE ) && !defined( VULKAN_HPP_STD_MODULE )
# include <tuple> // std::tie
# include <vector> // std::vector
#endif

#if !defined( VULKAN_HPP_NO_EXCEPTIONS )
#if !defined( VULKAN_HPP_NO_EXCEPTIONS ) && !defined( VULKAN_HPP_STD_MODULE )
# include <system_error> // std::is_error_code_enum
#endif

Expand All @@ -39,10 +42,10 @@ extern "C" __declspec( dllimport ) FARPROC __stdcall GetProcAddress( HINSTANCE h
# endif
#endif

#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR )
#if defined( VULKAN_HPP_HAS_SPACESHIP_OPERATOR ) && !defined( VULKAN_HPP_STD_MODULE )
# include <compare>
#endif

#if defined( VULKAN_HPP_SUPPORT_SPAN )
#if defined( VULKAN_HPP_SUPPORT_SPAN ) && !defined( VULKAN_HPP_STD_MODULE )
# include <span>
#endif
10 changes: 8 additions & 2 deletions snippets/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
# define VULKAN_HPP_SUPPORT_SPAN
#endif

#if !defined( VULKAN_HPP_STD_MODULE ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_modules ) && defined( VULKAN_HPP_ENABLE_STD_MODULE )
# define VULKAN_HPP_STD_MODULE std
# define VULKAN_HPP_STD_COMPAT_MODULE std.compat
#endif

// 32-bit vulkan is not typesafe for non-dispatchable handles, so don't allow copy constructors on this platform by default.
// To enable this feature on 32-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 1
// To disable this feature on 64-bit platforms please #define VULKAN_HPP_TYPESAFE_CONVERSION 0
Expand All @@ -86,7 +91,6 @@
# endif
#endif


#if defined( __GNUC__ )
# define GCC_VERSION ( __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ )
#endif
Expand Down Expand Up @@ -270,7 +274,9 @@ namespace VULKAN_HPP_NAMESPACE
#endif

#if !defined( VULKAN_HPP_EXPECTED ) && ( 23 <= VULKAN_HPP_CPP_VERSION ) && defined( __cpp_lib_expected )
# include <expected>
# if !defined( VULKAN_HPP_STD_MODULE )
# include <expected>
# endif
# define VULKAN_HPP_EXPECTED std::expected
# define VULKAN_HPP_UNEXPECTED std::unexpected
#endif
Expand Down

0 comments on commit 8f253dc

Please sign in to comment.