This commit is contained in:
Reece Wilson 2024-09-13 09:37:56 +01:00
parent 11bb77f129
commit 6d73e2bc66
2 changed files with 37 additions and 16 deletions

View File

@ -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
#if defined(AURORA_ROXTL_HAS_RUNTIME) && AURORA_ROXTL_HAS_RUNTIME
@ -57,13 +65,13 @@ using AuHUPOf_t = AuUPtr<T, void(*)(T *)>;
template <class T>
auto AuNullHeapPointer()
{
return AuHeapNullUniquePointer<T>();
return AuUPtr<T>();
}
template <class T>
auto AuNullPointer()
{
return AuHeapNullUniquePointer<T>();
return AuUPtr<T>();
}
template <class T, class ...Args>

View File

@ -110,7 +110,32 @@ struct AU_ALIGN(sizeof(AuUInt)) 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) \
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__)
#define AUROXTL_INTERFACE_SOO_HDR(Type, extends, targetSize, ...) \
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)...); \
}
AUROXTL_INTERFACE_SOO_HDR_EX(, Type, extends, targetSize, ## __VA_ARGS__)
#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))) \