From 8ac5ba9bbb806cee3695486df1f259bd41ea6770 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/object2/DArray.hpp | 2 +- include/xo/object2/DBoolean.hpp | 2 +- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DFloat.hpp | 2 +- include/xo/object2/DInteger.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/DRuntimeError.hpp | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 2 +- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 2 +- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 2 +- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 2 +- include/xo/object2/list/IGCObject_DList.hpp | 2 +- include/xo/object2/number/IGCObject_DFloat.hpp | 2 +- include/xo/object2/number/IGCObject_DInteger.hpp | 2 +- src/object2/DArray.cpp | 7 +++++-- src/object2/DBoolean.cpp | 9 ++------- src/object2/DDictionary.cpp | 4 ++-- src/object2/DFloat.cpp | 9 ++------- src/object2/DInteger.cpp | 9 ++------- src/object2/DList.cpp | 4 ++-- src/object2/DRuntimeError.cpp | 9 ++------- src/object2/IGCObject_DArray.cpp | 4 ++-- src/object2/IGCObject_DBoolean.cpp | 4 ++-- src/object2/IGCObject_DDictionary.cpp | 4 ++-- src/object2/IGCObject_DFloat.cpp | 4 ++-- src/object2/IGCObject_DInteger.cpp | 4 ++-- src/object2/IGCObject_DList.cpp | 4 ++-- src/object2/IGCObject_DRuntimeError.cpp | 4 ++-- 28 files changed, 45 insertions(+), 62 deletions(-) diff --git a/include/xo/object2/DArray.hpp b/include/xo/object2/DArray.hpp index 99d1b3d7..a455046d 100644 --- a/include/xo/object2/DArray.hpp +++ b/include/xo/object2/DArray.hpp @@ -148,7 +148,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DArray * shallow_move(obj mm) const noexcept; + DArray * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DBoolean.hpp b/include/xo/object2/DBoolean.hpp index 34ffda16..31bf41b7 100644 --- a/include/xo/object2/DBoolean.hpp +++ b/include/xo/object2/DBoolean.hpp @@ -38,7 +38,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DBoolean * shallow_move(obj mm) const noexcept; + DBoolean * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 5e6ecaec..219e7838 100644 --- a/include/xo/object2/DDictionary.hpp +++ b/include/xo/object2/DDictionary.hpp @@ -203,7 +203,7 @@ namespace xo { /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ - DDictionary * shallow_move(obj mm) noexcept; + DDictionary * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DFloat.hpp b/include/xo/object2/DFloat.hpp index b7d56e9c..949883ab 100644 --- a/include/xo/object2/DFloat.hpp +++ b/include/xo/object2/DFloat.hpp @@ -35,7 +35,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DFloat * shallow_move(obj mm) const noexcept; + DFloat * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DInteger.hpp b/include/xo/object2/DInteger.hpp index 6a6194bf..d3969b75 100644 --- a/include/xo/object2/DInteger.hpp +++ b/include/xo/object2/DInteger.hpp @@ -40,7 +40,7 @@ namespace xo { // GCObject facet std::size_t shallow_size() const noexcept; - DInteger * shallow_move(obj mm) const noexcept; + DInteger * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; private: diff --git a/include/xo/object2/DList.hpp b/include/xo/object2/DList.hpp index 8fff47d5..199ec6e5 100644 --- a/include/xo/object2/DList.hpp +++ b/include/xo/object2/DList.hpp @@ -70,7 +70,7 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ size_type shallow_size() const noexcept; - DList * shallow_move(obj mm) noexcept; + DList * shallow_move(obj gc) noexcept; size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/DRuntimeError.hpp b/include/xo/object2/DRuntimeError.hpp index 957c8481..2ee93061 100644 --- a/include/xo/object2/DRuntimeError.hpp +++ b/include/xo/object2/DRuntimeError.hpp @@ -50,7 +50,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DRuntimeError * shallow_move(obj mm) const noexcept; + DRuntimeError * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index ab8a85f1..58c202d7 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DArray & self, obj mm) noexcept; + static Opaque shallow_move(DArray & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DArray & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/boolean/IGCObject_DBoolean.hpp b/include/xo/object2/boolean/IGCObject_DBoolean.hpp index 5bc6e0c0..3ca03921 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DBoolean & self, obj mm) noexcept; + static Opaque shallow_move(DBoolean & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DBoolean & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp index 16fef8cb..b6da10c0 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DDictionary & self, obj mm) noexcept; + static Opaque shallow_move(DDictionary & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDictionary & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/error/IGCObject_DRuntimeError.hpp b/include/xo/object2/error/IGCObject_DRuntimeError.hpp index 62cc6109..42e273ec 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DRuntimeError & self, obj mm) noexcept; + static Opaque shallow_move(DRuntimeError & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DRuntimeError & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/list/IGCObject_DList.hpp b/include/xo/object2/list/IGCObject_DList.hpp index 780ebda5..7218556a 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DList & self, obj mm) noexcept; + static Opaque shallow_move(DList & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DList & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DFloat.hpp b/include/xo/object2/number/IGCObject_DFloat.hpp index b25e4626..88d4d563 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -54,7 +54,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DFloat & self, obj mm) noexcept; + static Opaque shallow_move(DFloat & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DFloat & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/number/IGCObject_DInteger.hpp b/include/xo/object2/number/IGCObject_DInteger.hpp index a87f253a..822ec168 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DInteger & self, obj mm) noexcept; + static Opaque shallow_move(DInteger & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DInteger & self, obj gc) noexcept; ///@} diff --git a/src/object2/DArray.cpp b/src/object2/DArray.cpp index 2ae4ddc6..a70213f1 100644 --- a/src/object2/DArray.cpp +++ b/src/object2/DArray.cpp @@ -181,9 +181,12 @@ namespace xo { } DArray * - DArray::shallow_move(obj mm) const noexcept + DArray::shallow_move(obj gc) noexcept { - DArray * copy = (DArray *)mm.alloc_copy((std::byte *)this); + // note: not using gc.std_copy_for() here. + // flexible array -> compiler doesn't know actual DArray allocation size + + DArray * copy = (DArray *)gc.alloc_copy((std::byte *)this); if (copy) { copy->capacity_ = capacity_; diff --git a/src/object2/DBoolean.cpp b/src/object2/DBoolean.cpp index cb25f9e0..a8d5e85f 100644 --- a/src/object2/DBoolean.cpp +++ b/src/object2/DBoolean.cpp @@ -36,14 +36,9 @@ namespace xo { } DBoolean * - DBoolean::shallow_move(obj mm) const noexcept + DBoolean::shallow_move(obj gc) noexcept { - DBoolean * copy = (DBoolean *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index 739fcedc..2f25f1b7 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,9 +274,9 @@ namespace xo { } DDictionary * - DDictionary::shallow_move(obj mm) noexcept + DDictionary::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/object2/DFloat.cpp b/src/object2/DFloat.cpp index f7f8ff3e..4a9041c0 100644 --- a/src/object2/DFloat.cpp +++ b/src/object2/DFloat.cpp @@ -34,14 +34,9 @@ namespace xo { } DFloat * - DFloat::shallow_move(obj mm) const noexcept + DFloat::shallow_move(obj gc) noexcept { - DFloat * copy = (DFloat *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DInteger.cpp b/src/object2/DInteger.cpp index 7cbcedf0..600f48ec 100644 --- a/src/object2/DInteger.cpp +++ b/src/object2/DInteger.cpp @@ -34,14 +34,9 @@ namespace xo { } DInteger * - DInteger::shallow_move(obj mm) const noexcept + DInteger::shallow_move(obj gc) noexcept { - DInteger * copy = (DInteger *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index be869073..f17a53f4 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,9 +185,9 @@ namespace xo { } DList * - DList::shallow_move(obj mm) noexcept + DList::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } auto diff --git a/src/object2/DRuntimeError.cpp b/src/object2/DRuntimeError.cpp index 1f34596b..a52e1df9 100644 --- a/src/object2/DRuntimeError.cpp +++ b/src/object2/DRuntimeError.cpp @@ -59,14 +59,9 @@ namespace xo { } DRuntimeError * - DRuntimeError::shallow_move(obj mm) const noexcept + DRuntimeError::shallow_move(obj gc) noexcept { - DRuntimeError * copy = (DRuntimeError *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 7cde63e1..e4fa31c7 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DArray::shallow_move(DArray & self, obj mm) noexcept -> Opaque + IGCObject_DArray::shallow_move(DArray & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DArray::forward_children(DArray & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DBoolean.cpp b/src/object2/IGCObject_DBoolean.cpp index ef503af9..2aed50e3 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DBoolean::shallow_move(DBoolean & self, obj mm) noexcept -> Opaque + IGCObject_DBoolean::shallow_move(DBoolean & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DBoolean::forward_children(DBoolean & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DDictionary.cpp b/src/object2/IGCObject_DDictionary.cpp index 9d4bae65..e8f291aa 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DDictionary::shallow_move(DDictionary & self, obj mm) noexcept -> Opaque + IGCObject_DDictionary::shallow_move(DDictionary & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DDictionary::forward_children(DDictionary & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DFloat.cpp b/src/object2/IGCObject_DFloat.cpp index a22a1b2f..7625cacb 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DFloat::shallow_move(DFloat & self, obj mm) noexcept -> Opaque + IGCObject_DFloat::shallow_move(DFloat & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DFloat::forward_children(DFloat & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DInteger.cpp b/src/object2/IGCObject_DInteger.cpp index 4f74e5fe..9bb9bbf3 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DInteger::shallow_move(DInteger & self, obj mm) noexcept -> Opaque + IGCObject_DInteger::shallow_move(DInteger & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DInteger::forward_children(DInteger & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 2512cc32..cbe8b71e 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DList::shallow_move(DList & self, obj mm) noexcept -> Opaque + IGCObject_DList::shallow_move(DList & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DList::forward_children(DList & self, obj gc) noexcept -> size_type diff --git a/src/object2/IGCObject_DRuntimeError.cpp b/src/object2/IGCObject_DRuntimeError.cpp index cc755821..6917af76 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj mm) noexcept -> Opaque + IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type