[*] Amend: 11bb77f1
This commit is contained in:
parent
11bb77f129
commit
5c1f608cf2
@ -1,3 +1,11 @@
|
|||||||
|
/***
|
||||||
|
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||||
|
|
||||||
|
File: auMemoryAllocate.hpp
|
||||||
|
Date: 2024-09-13
|
||||||
|
Date: 2024-02-13
|
||||||
|
Author: Reece
|
||||||
|
***/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(AURORA_ROXTL_HAS_RUNTIME) && AURORA_ROXTL_HAS_RUNTIME
|
#if defined(AURORA_ROXTL_HAS_RUNTIME) && AURORA_ROXTL_HAS_RUNTIME
|
||||||
@ -57,13 +65,13 @@ using AuHUPOf_t = AuUPtr<T, void(*)(T *)>;
|
|||||||
template <class T>
|
template <class T>
|
||||||
auto AuNullHeapPointer()
|
auto AuNullHeapPointer()
|
||||||
{
|
{
|
||||||
return AuHeapNullUniquePointer<T>();
|
return AuUPtr<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
auto AuNullPointer()
|
auto AuNullPointer()
|
||||||
{
|
{
|
||||||
return AuHeapNullUniquePointer<T>();
|
return AuUPtr<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class ...Args>
|
template <class T, class ...Args>
|
||||||
@ -146,5 +154,5 @@ template <class Z, class T>
|
|||||||
AuHUPOf_t<Z> AuCastPointer(AuHUPOf_t<T> &&pInPointer)
|
AuHUPOf_t<Z> AuCastPointer(AuHUPOf_t<T> &&pInPointer)
|
||||||
{
|
{
|
||||||
// TODO: we can do better with this memory model update
|
// TODO: we can do better with this memory model update
|
||||||
return AuHeapCastPointer<Z>(AuMove(pInPointer));
|
return AuHeap::CastPointer<Z>(AuMove(pInPointer));
|
||||||
}
|
}
|
@ -143,12 +143,7 @@ public:
|
|||||||
AuUInt CopyInto(const AuMemoryView<false> &write) const;
|
AuUInt CopyInto(const AuMemoryView<false> &write) const;
|
||||||
|
|
||||||
template<bool bThat = Readonly_b, AU_TEMPLATE_ENABLE_WHEN(!bThat)>
|
template<bool bThat = Readonly_b, AU_TEMPLATE_ENABLE_WHEN(!bThat)>
|
||||||
AuUInt CopyFrom(const AuMemoryView<true> &read) const
|
AuUInt CopyFrom(const AuMemoryView<true> &read) const;
|
||||||
{
|
|
||||||
auto uLength = AuMin(this->uLength, read.uLength);
|
|
||||||
AuMemcpy(this->pBase, read.pBase, uLength);
|
|
||||||
return uLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasControlBlock() const;
|
bool HasControlBlock() const;
|
||||||
|
|
||||||
@ -280,30 +275,14 @@ struct AuMemoryViewStream : AuMemoryView<Readonly_b>
|
|||||||
outVariable = 0;
|
outVariable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool HasMemory() const
|
constexpr bool HasMemory() const;
|
||||||
{
|
|
||||||
return this->ptr && this->length;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr operator bool() const
|
constexpr operator bool() const;
|
||||||
{
|
|
||||||
return HasMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CopyStreamInto(const AuMemoryView<false> &write) const
|
void CopyStreamInto(const AuMemoryView<false> &write) const;
|
||||||
{
|
|
||||||
auto uLength = AuMin(this->uLength, write.uLength);
|
|
||||||
AuMemcpy(write.pBase, this->pBase, uLength);
|
|
||||||
this->outVariable = uLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<bool bThat = Readonly_b, AU_TEMPLATE_ENABLE_WHEN(!bThat)>
|
template<bool bThat = Readonly_b, AU_TEMPLATE_ENABLE_WHEN(!bThat)>
|
||||||
void CopyStreamFrom(const AuMemoryView<true> &read) const
|
void CopyStreamFrom(const AuMemoryView<true> &read) const;
|
||||||
{
|
|
||||||
auto uLength = AuMin(this->uLength, read.uLength);
|
|
||||||
AuMemcpy(this->pBase, read.pBase, uLength);
|
|
||||||
this->outVariable = uLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
AuUInt &outVariable;
|
AuUInt &outVariable;
|
||||||
private:
|
private:
|
||||||
|
@ -622,3 +622,40 @@ AuUInt AuMemoryView<Readonly_b>::CopyInto(const AuMemoryView<false> &write) cons
|
|||||||
return uLength;
|
return uLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<bool Readonly_b>
|
||||||
|
template<bool bThat, typename AuEnableIf<!bThat>::type *>
|
||||||
|
inline AuUInt AuMemoryView<Readonly_b>::CopyFrom(const AuMemoryView<true> &read) const
|
||||||
|
{
|
||||||
|
auto uLength = AuMin(this->uLength, read.uLength);
|
||||||
|
AuMemcpy(this->pBase, read.pBase, uLength);
|
||||||
|
return uLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Readonly_b>
|
||||||
|
constexpr bool AuMemoryViewStream<Readonly_b>::HasMemory() const
|
||||||
|
{
|
||||||
|
return this->ptr && this->length;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Readonly_b>
|
||||||
|
constexpr AuMemoryViewStream<Readonly_b>::operator bool() const
|
||||||
|
{
|
||||||
|
return HasMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Readonly_b>
|
||||||
|
inline void AuMemoryViewStream<Readonly_b>::CopyStreamInto(const AuMemoryView<false> &write) const
|
||||||
|
{
|
||||||
|
auto uLength = AuMin(this->uLength, write.uLength);
|
||||||
|
AuMemcpy(write.pBase, this->pBase, uLength);
|
||||||
|
this->outVariable = uLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Readonly_b>
|
||||||
|
template<bool bThat, typename AuEnableIf<!bThat>::type *>
|
||||||
|
inline void AuMemoryViewStream<Readonly_b>::CopyStreamFrom(const AuMemoryView<true> &read) const
|
||||||
|
{
|
||||||
|
auto uLength = AuMin(this->uLength, read.uLength);
|
||||||
|
AuMemcpy(this->pBase, read.pBase, uLength);
|
||||||
|
this->outVariable = uLength;
|
||||||
|
}
|
||||||
|
@ -110,7 +110,32 @@ struct AU_ALIGN(sizeof(AuUInt)) Type ## SOO
|
|||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
using Type ## SOO_t = Type ## SOO; \
|
using Type ## SOO_t = Type ## SOO; \
|
||||||
using Type = Type ## SOO;
|
using Type = Type ## SOO; \
|
||||||
|
\
|
||||||
|
template <class ... T> \
|
||||||
|
AuUPtr<extends> Type ## UniqueOnHeap(AuHeap *pHeap, T &&... args) \
|
||||||
|
{ \
|
||||||
|
auto pThat = pHeap->NewClassUnique<Type>(AuForward<T>(args)...); \
|
||||||
|
if (!pThat) \
|
||||||
|
{ \
|
||||||
|
return AuUPtr<extends> {}; \
|
||||||
|
} \
|
||||||
|
return AuUPtr<extends> { \
|
||||||
|
pThat.Release()->AsPointer(), \
|
||||||
|
((void (*)(extends *))pThat.GetDeleter()) \
|
||||||
|
}; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
template <class ... T> \
|
||||||
|
AuSPtr<extends> Type ## SharedOnHeap(AuHeap *pHeap, T &&... args) \
|
||||||
|
{ \
|
||||||
|
auto pThat = pHeap->NewClass<Type>(AuForward<T>(args)...); \
|
||||||
|
if (!pThat) \
|
||||||
|
{ \
|
||||||
|
return {}; \
|
||||||
|
} \
|
||||||
|
return { pThat, pThat->AsPointer() }; \
|
||||||
|
}
|
||||||
|
|
||||||
#define AU_SOO_MOVE_BASIC(Type) \
|
#define AU_SOO_MOVE_BASIC(Type) \
|
||||||
inline Type(Type &&that) \
|
inline Type(Type &&that) \
|
||||||
@ -172,19 +197,7 @@ using Type = Type ## SOO;
|
|||||||
AUROXTL_INTERFACE_SOO_HDR_EX2(vis, Type, extends, targetSize, (AU_NO_COPY_NO_MOVE(Type ## SOO)), ## __VA_ARGS__)
|
AUROXTL_INTERFACE_SOO_HDR_EX2(vis, Type, extends, targetSize, (AU_NO_COPY_NO_MOVE(Type ## SOO)), ## __VA_ARGS__)
|
||||||
|
|
||||||
#define AUROXTL_INTERFACE_SOO_HDR(Type, extends, targetSize, ...) \
|
#define AUROXTL_INTERFACE_SOO_HDR(Type, extends, targetSize, ...) \
|
||||||
AUROXTL_INTERFACE_SOO_HDR_EX(, Type, extends, targetSize, ## __VA_ARGS__) \
|
AUROXTL_INTERFACE_SOO_HDR_EX(, Type, extends, targetSize, ## __VA_ARGS__)
|
||||||
\
|
|
||||||
template <class ... T> \
|
|
||||||
extends ## Unique_t Type ## UniqueOnHeap(AuHeap *pHeap, T &&... args) \
|
|
||||||
{ \
|
|
||||||
return pHeap->NewClassUnique<Type>(AuForward<T>(args)...); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
template <class ... T> \
|
|
||||||
extends ## Shared_t Type ## SharedOnHeap(AuHeap *pHeap, T &&... args) \
|
|
||||||
{ \
|
|
||||||
return pHeap->NewClass<Type>(AuForward<T>(args)...); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define AUROXTL_INTERFACE_SOO_SRC_EX(vis, Type, FullType, ...) \
|
#define AUROXTL_INTERFACE_SOO_SRC_EX(vis, Type, FullType, ...) \
|
||||||
vis Type ## SOO::Type ## SOO(AU_FOR_EACH_FIRST(_AUROXTL_INTERRFACE_SOO_EMITTER_0, _AUROXTL_INTERRFACE_SOO_EMITTER_1, ## __VA_ARGS__, (AuUInt32, uSize))) \
|
vis Type ## SOO::Type ## SOO(AU_FOR_EACH_FIRST(_AUROXTL_INTERRFACE_SOO_EMITTER_0, _AUROXTL_INTERRFACE_SOO_EMITTER_1, ## __VA_ARGS__, (AuUInt32, uSize))) \
|
||||||
|
Loading…
Reference in New Issue
Block a user