mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Make Vulkan-Hpp namespace configurable. (#129)
This commit is contained in:
parent
daae0b6194
commit
b4694d931c
@ -24,6 +24,8 @@ To avoid name collisions with the Vulkan C API the C++ bindings reside in the vk
|
|||||||
* ```VK_STRUCTURE_TYPE_PRESENT_INFO_KHR``` is now ```vk::StructureType::ePresentInfoKHR```.
|
* ```VK_STRUCTURE_TYPE_PRESENT_INFO_KHR``` is now ```vk::StructureType::ePresentInfoKHR```.
|
||||||
* Flag bits are handled like scoped enums with the addition that the _BIT suffix has also been removed.
|
* Flag bits are handled like scoped enums with the addition that the _BIT suffix has also been removed.
|
||||||
|
|
||||||
|
In some cases it might be necessary to move Vulkan-Hpp to a custom namespace. This can be achieved by defining VULKAN_HPP_NAMESPACE before including Vulkan-Hpp.
|
||||||
|
|
||||||
# Handles
|
# Handles
|
||||||
Vulkan-Hpp declares a class for all handles to ensure full type safety and to add support for member functions on handles. A member function has been added to a handle class for each
|
Vulkan-Hpp declares a class for all handles to ensure full type safety and to add support for member functions on handles. A member function has been added to a handle class for each
|
||||||
function which accepts the corresponding handle as first parameter. Instead of ```vkBindBufferMemory(device, ...)``` one can write ```device.bindBufferMemory(...)``` or ```vk::bindBufferMemory(device, ...)```.
|
function which accepts the corresponding handle as first parameter. Instead of ```vkBindBufferMemory(device, ...)``` one can write ```device.bindBufferMemory(...)``` or ```vk::bindBufferMemory(device, ...)```.
|
||||||
|
@ -30,6 +30,15 @@
|
|||||||
|
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
|
|
||||||
|
const std::string vkNamespace = R"(
|
||||||
|
#if !defined(VULKAN_HPP_NAMESPACE)
|
||||||
|
#define VULKAN_HPP_NAMESPACE vk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace VULKAN_HPP_NAMESPACE
|
||||||
|
{
|
||||||
|
)";
|
||||||
|
|
||||||
const std::string exceptionHeader = R"(
|
const std::string exceptionHeader = R"(
|
||||||
#if defined(_MSC_VER) && (_MSC_VER == 1800)
|
#if defined(_MSC_VER) && (_MSC_VER == 1800)
|
||||||
# define noexcept _NOEXCEPT
|
# define noexcept _NOEXCEPT
|
||||||
@ -38,7 +47,7 @@ const std::string exceptionHeader = R"(
|
|||||||
class ErrorCategoryImpl : public std::error_category
|
class ErrorCategoryImpl : public std::error_category
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual const char* name() const noexcept override { return "vk::Result"; }
|
virtual const char* name() const noexcept override { return "VULKAN_HPP_NAMESPACE::Result"; }
|
||||||
virtual std::string message(int ev) const override { return to_string(static_cast<Result>(ev)); }
|
virtual std::string message(int ev) const override { return to_string(static_cast<Result>(ev)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2717,7 +2726,7 @@ ${i} assert( ${firstVectorName}.size() == ${secondVectorName}.size() );
|
|||||||
#else
|
#else
|
||||||
${i} if ( ${firstVectorName}.size() != ${secondVectorName}.size() )
|
${i} if ( ${firstVectorName}.size() != ${secondVectorName}.size() )
|
||||||
${i} {
|
${i} {
|
||||||
${i} throw LogicError( "vk::${className}::${reducedName}: ${firstVectorName}.size() != ${secondVectorName}.size()" );
|
${i} throw LogicError( "VULKAN_HPP_NAMESPACE::${className}::${reducedName}: ${firstVectorName}.size() != ${secondVectorName}.size()" );
|
||||||
${i} }
|
${i} }
|
||||||
#endif // VULKAN_HPP_NO_EXCEPTIONS
|
#endif // VULKAN_HPP_NO_EXCEPTIONS
|
||||||
)#";
|
)#";
|
||||||
@ -2756,7 +2765,7 @@ void writeFunctionBodyEnhancedReturnResultValue(std::ostream & os, std::string c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// now the function name (with full namespace) as a string
|
// now the function name (with full namespace) as a string
|
||||||
os << "\"vk::" << (commandData.className.empty() ? "" : commandData.className + "::") << (singular ? stripPluralS(commandData.reducedName) : commandData.reducedName) << "\"";
|
os << "\"VULKAN_HPP_NAMESPACE::" << (commandData.className.empty() ? "" : commandData.className + "::") << (singular ? stripPluralS(commandData.reducedName) : commandData.reducedName) << "\"";
|
||||||
|
|
||||||
if (!commandData.twoStep && (1 < commandData.successCodes.size()))
|
if (!commandData.twoStep && (1 < commandData.successCodes.size()))
|
||||||
{
|
{
|
||||||
@ -4330,8 +4339,7 @@ int main( int argc, char **argv )
|
|||||||
<< inlineHeader
|
<< inlineHeader
|
||||||
<< explicitHeader
|
<< explicitHeader
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "namespace vk" << std::endl
|
<< vkNamespace
|
||||||
<< "{" << std::endl
|
|
||||||
<< flagsHeader
|
<< flagsHeader
|
||||||
<< optionalClassHeader
|
<< optionalClassHeader
|
||||||
<< arrayProxyHeader
|
<< arrayProxyHeader
|
||||||
@ -4351,16 +4359,16 @@ int main( int argc, char **argv )
|
|||||||
ofs << "#endif" << std::endl;
|
ofs << "#endif" << std::endl;
|
||||||
vkData.dependencies.erase(it);
|
vkData.dependencies.erase(it);
|
||||||
|
|
||||||
ofs << "} // namespace vk" << std::endl
|
ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "namespace std" << std::endl
|
<< "namespace std" << std::endl
|
||||||
<< "{" << std::endl
|
<< "{" << std::endl
|
||||||
<< " template <>" << std::endl
|
<< " template <>" << std::endl
|
||||||
<< " struct is_error_code_enum<vk::Result> : public true_type" << std::endl
|
<< " struct is_error_code_enum<VULKAN_HPP_NAMESPACE::Result> : public true_type" << std::endl
|
||||||
<< " {};" << std::endl
|
<< " {};" << std::endl
|
||||||
<< "}" << std::endl
|
<< "}" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "namespace vk" << std::endl
|
<< "namespace VULKAN_HPP_NAMESPACE" << std::endl
|
||||||
<< "{" << std::endl
|
<< "{" << std::endl
|
||||||
<< resultValueHeader
|
<< resultValueHeader
|
||||||
<< createResultValueHeader;
|
<< createResultValueHeader;
|
||||||
@ -4394,7 +4402,7 @@ int main( int argc, char **argv )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs << "} // namespace vk" << std::endl
|
ofs << "} // namespace VULKAN_HPP_NAMESPACE" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< "#endif" << std::endl;
|
<< "#endif" << std::endl;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user