From 6d73e2bc660e5a058d53de6d6f5994b482738dcc Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 13 Sep 2024 09:37:56 +0100 Subject: [PATCH] [*] Amend: 11bb77f1 --- .../auROXTL/MemoryModel/auMemoryAllocate.hpp | 12 +++++- Include/auROXTL/Objects/SOO.hpp | 41 ++++++++++++------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Include/auROXTL/MemoryModel/auMemoryAllocate.hpp b/Include/auROXTL/MemoryModel/auMemoryAllocate.hpp index d0451e6..0501ae3 100755 --- a/Include/auROXTL/MemoryModel/auMemoryAllocate.hpp +++ b/Include/auROXTL/MemoryModel/auMemoryAllocate.hpp @@ -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; template auto AuNullHeapPointer() { - return AuHeapNullUniquePointer(); + return AuUPtr(); } template auto AuNullPointer() { - return AuHeapNullUniquePointer(); + return AuUPtr(); } template diff --git a/Include/auROXTL/Objects/SOO.hpp b/Include/auROXTL/Objects/SOO.hpp index 5fb6e02..a2a5aa2 100644 --- a/Include/auROXTL/Objects/SOO.hpp +++ b/Include/auROXTL/Objects/SOO.hpp @@ -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 \ + AuUPtr Type ## UniqueOnHeap(AuHeap *pHeap, T &&... args) \ + { \ + auto pThat = pHeap->NewClassUnique(AuForward(args)...); \ + if (!pThat) \ + { \ + return AuUPtr {}; \ + } \ + return AuUPtr { \ + pThat.Release()->AsPointer(), \ + ((void (*)(extends *))pThat.GetDeleter()) \ + }; \ + } \ + \ + template \ + AuSPtr Type ## SharedOnHeap(AuHeap *pHeap, T &&... args) \ + { \ + auto pThat = pHeap->NewClass(AuForward(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 \ - extends ## Unique_t Type ## UniqueOnHeap(AuHeap *pHeap, T &&... args) \ - { \ - return pHeap->NewClassUnique(AuForward(args)...); \ - } \ - \ - template \ - extends ## Shared_t Type ## SharedOnHeap(AuHeap *pHeap, T &&... args) \ - { \ - return pHeap->NewClass(AuForward(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))) \