From b88d181906270a6738f1dafcffc8ec24648b8e8b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 14:38:14 -0400 Subject: [PATCH] refactor: make AGCObject.shallow_copy() non-const prep for moving to ACollector interface --- idl/GCObject.json5 | 8 ++++---- include/xo/alloc2/gc/AGCObject.hpp | 4 ++-- include/xo/alloc2/gc/IGCObject_Any.hpp | 2 +- include/xo/alloc2/gc/IGCObject_Xfer.hpp | 6 +++--- include/xo/alloc2/gc/RGCObject.hpp | 6 +++--- src/alloc2/IGCObject_Any.cpp | 6 ++++++ 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/idl/GCObject.json5 b/idl/GCObject.json5 index 0bbb170d..cbc2ab7e 100644 --- a/idl/GCObject.json5 +++ b/idl/GCObject.json5 @@ -54,7 +54,9 @@ noexcept: true, attributes: [], }, - // Opaque shallow_copy(obj>) const noexcept + ], + nonconst_methods: [ + // Opaque shallow_copy(obj>) noexcept { name: "shallow_copy", doc: ["copy instance using allocator"], @@ -66,9 +68,7 @@ noexcept: true, attributes: [], }, - ], - nonconst_methods: [ - // size_type forward_children(obj) const noexcept + // size_type forward_children(obj) noexcept { name: "forward_children", doc: ["during GC: forward immdiate children"], diff --git a/include/xo/alloc2/gc/AGCObject.hpp b/include/xo/alloc2/gc/AGCObject.hpp index 1037f253..e9a4e519 100644 --- a/include/xo/alloc2/gc/AGCObject.hpp +++ b/include/xo/alloc2/gc/AGCObject.hpp @@ -64,10 +64,10 @@ public: virtual void _drop(Opaque d) const noexcept = 0; /** memory consumption for this instance **/ virtual size_type shallow_size(Copaque data) const noexcept = 0; - /** copy instance using allocator **/ - virtual Opaque shallow_copy(Copaque data, obj mm) const noexcept = 0; // nonconst methods + /** copy instance using allocator **/ + virtual Opaque shallow_copy(Opaque data, obj mm) const noexcept = 0; /** during GC: forward immdiate children **/ virtual size_type forward_children(Opaque data, obj gc) const noexcept = 0; ///@} diff --git a/include/xo/alloc2/gc/IGCObject_Any.hpp b/include/xo/alloc2/gc/IGCObject_Any.hpp index 9ff7bb2e..2658c599 100644 --- a/include/xo/alloc2/gc/IGCObject_Any.hpp +++ b/include/xo/alloc2/gc/IGCObject_Any.hpp @@ -62,9 +62,9 @@ namespace mm { // const methods [[noreturn]] size_type shallow_size(Copaque) const noexcept override { _fatal(); } - [[noreturn]] Opaque shallow_copy(Copaque, obj) const noexcept override { _fatal(); } // nonconst methods + [[noreturn]] Opaque shallow_copy(Opaque, obj) const noexcept override; [[noreturn]] size_type forward_children(Opaque, obj) const noexcept override; ///@} diff --git a/include/xo/alloc2/gc/IGCObject_Xfer.hpp b/include/xo/alloc2/gc/IGCObject_Xfer.hpp index 12010edf..e00595e8 100644 --- a/include/xo/alloc2/gc/IGCObject_Xfer.hpp +++ b/include/xo/alloc2/gc/IGCObject_Xfer.hpp @@ -52,11 +52,11 @@ namespace mm { size_type shallow_size(Copaque data) const noexcept override { return I::shallow_size(_dcast(data)); } - Opaque shallow_copy(Copaque data, obj mm) const noexcept override { - return I::shallow_copy(_dcast(data), mm); - } // non-const methods + Opaque shallow_copy(Opaque data, obj mm) const noexcept override { + return I::shallow_copy(_dcast(data), mm); + } size_type forward_children(Opaque data, obj gc) const noexcept override { return I::forward_children(_dcast(data), gc); } diff --git a/include/xo/alloc2/gc/RGCObject.hpp b/include/xo/alloc2/gc/RGCObject.hpp index d24994a8..c4a668e6 100644 --- a/include/xo/alloc2/gc/RGCObject.hpp +++ b/include/xo/alloc2/gc/RGCObject.hpp @@ -58,11 +58,11 @@ public: size_type shallow_size() const noexcept { return O::iface()->shallow_size(O::data()); } - Opaque shallow_copy(obj mm) const noexcept { - return O::iface()->shallow_copy(O::data(), mm); - } // non-const methods (still const in router!) + Opaque shallow_copy(obj mm) noexcept { + return O::iface()->shallow_copy(O::data(), mm); + } size_type forward_children(obj gc) noexcept { return O::iface()->forward_children(O::data(), gc); } diff --git a/src/alloc2/IGCObject_Any.cpp b/src/alloc2/IGCObject_Any.cpp index 10ff8f6a..426f68a9 100644 --- a/src/alloc2/IGCObject_Any.cpp +++ b/src/alloc2/IGCObject_Any.cpp @@ -35,6 +35,12 @@ IGCObject_Any::_valid // nonconst methods +auto +IGCObject_Any::shallow_copy(Opaque, obj) const noexcept -> Opaque +{ + _fatal(); +} + auto IGCObject_Any::forward_children(Opaque, obj) const noexcept -> size_type {