[*] Additional seething

This commit is contained in:
Reece Wilson 2022-03-13 16:48:05 +00:00
parent 260442a684
commit 5213a19362
2 changed files with 218 additions and 12 deletions

View File

@ -7,6 +7,8 @@
***/
#pragma once
#include <auROXTL/auCopyMoveUtils.hpp>
namespace Aurora::Memory
{
namespace _detail
@ -28,9 +30,9 @@ namespace Aurora::Memory
}
template<class TType_t, class Base_t>
struct ExSharedPtr : public Base_t
struct ExSharedPtr : Base_t
#if !defined(_AURORA_NULLEXPT_ENABLE_UB) && !defined(_AURORA_NULLEXPT_BRANCH)
, _detail::IPtrGet
, private _detail::IPtrGet
#endif
{
using element_type = Base_t::element_type;
@ -38,13 +40,80 @@ namespace Aurora::Memory
using base_type = Base_t;
using Base_t::Base_t;
ExSharedPtr() : Base_t()
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(Base_t &&in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(ExSharedPtr &&in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const ExSharedPtr &in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<typename T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in) : Base_t(in.BasePointerType())
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<typename T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in) : Base_t(in.BasePointerType())
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<typename T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in, element_type *ptr) : Base_t(in.BasePointerType(), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(Base_t &&in, element_type *ptr) : Base_t(in, ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<typename T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in, element_type *ptr) : Base_t(in.BasePointerType(), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const Base_t &in, element_type *ptr) : Base_t(in, ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
ExSharedPtr(const Base_t &in) : Base_t(in)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -52,6 +121,41 @@ namespace Aurora::Memory
#endif
}
template<class Y = element_type, class Deleter_t, class Alloc_t>
ExSharedPtr(Y *in, Deleter_t del, Alloc_t alloc) : Base_t(in, del, alloc)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<class Y = element_type, class Deleter_t>
ExSharedPtr(Y *in, Deleter_t del) : Base_t(in, del)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template< class Y, class Deleter >
ExSharedPtr(AURORA_RUNTIME_AU_UNIQUE_PTR<Y, Deleter> &&r) : Base_t(r)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
template<typename T_t, typename B_t>
void swap(ExSharedPtr<T_t, B_t> &in)
{
Base_t::swap(in.BasePointerType());
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
}
void swap(Base_t &r)
{
Base_t::swap(r);
@ -64,16 +168,39 @@ namespace Aurora::Memory
void reset()
{
Base_t::reset();
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
#if !defined(_AURORA_NULLEXPT_BRANCH)
ptr = &_detail::gNoop;
#endif
#endif
}
operator Base_t() const noexcept
operator const Base_t &() const noexcept
{
return *this;
}
// required for move casts
operator Base_t &() noexcept
{
return *this;
}
const Base_t &BasePointerType() const noexcept
{
return *this;
}
Base_t &BasePointerType() noexcept
{
return *this;
}
operator bool() const noexcept
{
return Base_t::operator bool();
}
ExSharedPtr &operator =(const Base_t &in) noexcept
{
Base_t::operator=(in);
@ -84,6 +211,48 @@ namespace Aurora::Memory
return *this;
}
template<typename T_t, typename B_t>
ExSharedPtr &operator =(ExSharedPtr<T_t, B_t> &&in) noexcept
{
Base_t::operator=(AuMove(in.BasePointerType()));
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
ExSharedPtr &operator =(Base_t &&in) noexcept
{
Base_t::operator=(in);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
ExSharedPtr &operator =(const ExSharedPtr &in) noexcept
{
Base_t::operator=(in);
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
template<typename T_t, typename B_t>
ExSharedPtr &operator =(const ExSharedPtr<T_t, B_t> &in) noexcept
{
Base_t::operator=(in.BasePointerType());
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
_cache();
#endif
return *this;
}
template<typename TType2_t = TType_t>
TType2_t &operator*() const
{
@ -122,10 +291,47 @@ namespace Aurora::Memory
#endif
}
element_type *get() const
{
return Base_t::get();
}
#define ADD_OPERATOR(op) \
template<class T > \
bool operator op(const T &rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
} \
\
template< class T > \
bool operator op(std::nullptr_t rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
}
ADD_OPERATOR(==)
ADD_OPERATOR(!=)
#if defined(AU_LANG_CPP_20)
template< class T >
std::strong_ordering operator<=>(const T &rhs) noexcept
{
return Base_t::operator<=>(rhs);
}
#else
ADD_OPERATOR(>)
ADD_OPERATOR(<)
ADD_OPERATOR(<=)
ADD_OPERATOR(=>)
#endif
private:
#if !defined(_AURORA_NULLEXPT_BRANCH)
_detail::IPtrGet *ptr = this;
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
void _cache()
{}
#elif !defined(_AURORA_NULLEXPT_BRANCH)
_detail::IPtrGet * ptr;
inline virtual void *Get() override
{
@ -145,11 +351,6 @@ namespace Aurora::Memory
}
}
#else
auline void _cache()
{
cached = Base_t::operator bool();
}
auline void throwif() const
{
if (!cached) [[unlikely]]
@ -172,6 +373,11 @@ namespace Aurora::Memory
}
}
}
auline void _cache()
{
cached = Base_t::operator bool();
}
#endif
};

View File

@ -79,7 +79,7 @@ namespace Aurora::Console::Commands
auto const &cmdEntry = cmdItr->second;
offset = 0;
Parse::ParseState consumable(AuIO::Character::ProviderFromStringUnique(cmdParse, offset));
Parse::ParseState consumable(AuIO::Character::ProviderFromStringShared(cmdParse, offset));
auto status = Parse::Parse(consumable, cmdEntry.commandStructure, res);
if (!status)