Add constructor to Optional<RefType> which accepts a RefType* in addition RefType& and nullptr. This is required since *nullptr is illegal and writing (ptr == nullptr) ? nullptr : *ptr isn't an efficient solution for the problem. (#45)
This commit is contained in:
parent
952667d3c0
commit
3e3c16a0a1
@ -136,11 +136,11 @@ const std::string flagsHeader(
|
|||||||
" return !m_mask;\n"
|
" return !m_mask;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Flags<BitType> operator~() const\n"
|
" Flags<BitType> operator~() const\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" Flags<BitType> result(*this);\n"
|
" Flags<BitType> result(*this);\n"
|
||||||
" result.m_mask ^= FlagTraits<BitType>::allFlags;\n"
|
" result.m_mask ^= FlagTraits<BitType>::allFlags;\n"
|
||||||
" return result;\n"
|
" return result;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
"\n"
|
"\n"
|
||||||
" bool operator==(Flags<BitType> const& rhs) const\n"
|
" bool operator==(Flags<BitType> const& rhs) const\n"
|
||||||
@ -187,23 +187,24 @@ const std::string flagsHeader(
|
|||||||
"\n"
|
"\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string const optionalClassHeader = (
|
std::string const optionalClassHeader = R"(
|
||||||
" template <typename RefType>\n"
|
template <typename RefType>
|
||||||
" class Optional\n"
|
class Optional
|
||||||
" {\n"
|
{
|
||||||
" public:\n"
|
public:
|
||||||
" Optional(RefType & reference) { m_ptr = &reference; }\n"
|
Optional(RefType & reference) { m_ptr = &reference; }
|
||||||
" Optional(std::nullptr_t) { m_ptr = nullptr; }\n"
|
Optional(RefType * ptr) { m_ptr = ptr; }
|
||||||
"\n"
|
Optional(std::nullptr_t) { m_ptr = nullptr; }
|
||||||
" operator RefType*() const { return m_ptr; }\n"
|
|
||||||
" RefType const* operator->() const { return m_ptr; }\n"
|
operator RefType*() const { return m_ptr; }
|
||||||
" explicit operator bool() const { return !!m_ptr; }\n"
|
RefType const* operator->() const { return m_ptr; }
|
||||||
"\n"
|
explicit operator bool() const { return !!m_ptr; }
|
||||||
" private:\n"
|
|
||||||
" RefType *m_ptr;\n"
|
private:
|
||||||
" };\n"
|
RefType *m_ptr;
|
||||||
"\n"
|
};
|
||||||
);
|
|
||||||
|
)";
|
||||||
|
|
||||||
std::string const arrayProxyHeader = (
|
std::string const arrayProxyHeader = (
|
||||||
"#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE\n"
|
"#ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE\n"
|
||||||
@ -2680,21 +2681,21 @@ void writeTypeFlags(std::ofstream & ofs, DependencyData const& dependencyData, F
|
|||||||
<< " return ~( " << dependencyData.name << "( bits ) );" << std::endl
|
<< " return ~( " << dependencyData.name << "( bits ) );" << std::endl
|
||||||
<< " }" << std::endl
|
<< " }" << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< " template <> struct FlagTraits<" << *dependencyData.dependencies.begin() << ">" << std::endl
|
<< " template <> struct FlagTraits<" << *dependencyData.dependencies.begin() << ">" << std::endl
|
||||||
<< " {" << std::endl
|
<< " {" << std::endl
|
||||||
<< " enum" << std::endl
|
<< " enum" << std::endl
|
||||||
<< " {" << std::endl
|
<< " {" << std::endl
|
||||||
<< " allFlags = ";
|
<< " allFlags = ";
|
||||||
for (size_t i = 0; i < enumData->second.members.size(); i++)
|
for (size_t i = 0; i < enumData->second.members.size(); i++)
|
||||||
{
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
ofs << " | ";
|
ofs << " | ";
|
||||||
}
|
}
|
||||||
ofs << "VkFlags(" << *dependencyData.dependencies.begin() << "::" << enumData->second.members[i].name << ")";
|
ofs << "VkFlags(" << *dependencyData.dependencies.begin() << "::" << enumData->second.members[i].name << ")";
|
||||||
}
|
}
|
||||||
ofs << std::endl
|
ofs << std::endl
|
||||||
<< " };" << std::endl
|
<< " };" << std::endl
|
||||||
<< " };" << std::endl;
|
<< " };" << std::endl;
|
||||||
}
|
}
|
||||||
leaveProtect(ofs, flagData.protect);
|
leaveProtect(ofs, flagData.protect);
|
||||||
|
@ -208,11 +208,13 @@ namespace vk
|
|||||||
return flags ^ bit;
|
return flags ^ bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename RefType>
|
template <typename RefType>
|
||||||
class Optional
|
class Optional
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Optional(RefType & reference) { m_ptr = &reference; }
|
Optional(RefType & reference) { m_ptr = &reference; }
|
||||||
|
Optional(RefType * ptr) { m_ptr = ptr; }
|
||||||
Optional(std::nullptr_t) { m_ptr = nullptr; }
|
Optional(std::nullptr_t) { m_ptr = nullptr; }
|
||||||
|
|
||||||
operator RefType*() const { return m_ptr; }
|
operator RefType*() const { return m_ptr; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user