From 24f857588c70b4e633c39c22a9ac35e5720149e3 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 --- include/xo/object2/DDictionary.hpp | 2 +- include/xo/object2/DList.hpp | 2 +- include/xo/object2/array/IGCObject_DArray.hpp | 4 ++-- include/xo/object2/boolean/IGCObject_DBoolean.hpp | 4 ++-- include/xo/object2/dictionary/IGCObject_DDictionary.hpp | 4 ++-- include/xo/object2/error/IGCObject_DRuntimeError.hpp | 4 ++-- include/xo/object2/list/IGCObject_DList.hpp | 4 ++-- include/xo/object2/number/IGCObject_DFloat.hpp | 4 ++-- include/xo/object2/number/IGCObject_DInteger.hpp | 4 ++-- include/xo/object2/sequence/ASequence.hpp | 5 +++++ src/object2/DDictionary.cpp | 2 +- src/object2/DList.cpp | 2 +- src/object2/IGCObject_DArray.cpp | 3 +-- src/object2/IGCObject_DBoolean.cpp | 3 +-- src/object2/IGCObject_DDictionary.cpp | 3 +-- src/object2/IGCObject_DFloat.cpp | 3 +-- src/object2/IGCObject_DInteger.cpp | 3 +-- src/object2/IGCObject_DList.cpp | 3 +-- src/object2/IGCObject_DRuntimeError.cpp | 3 +-- 19 files changed, 30 insertions(+), 32 deletions(-) diff --git a/include/xo/object2/DDictionary.hpp b/include/xo/object2/DDictionary.hpp index 63a7eba..1c77d2c 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_copy(obj mm) const noexcept; + DDictionary * shallow_copy(obj mm) 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/DList.hpp b/include/xo/object2/DList.hpp index ddc54f3..f6ea9d8 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_copy(obj mm) const noexcept; + DList * shallow_copy(obj mm) noexcept; size_type forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/object2/array/IGCObject_DArray.hpp b/include/xo/object2/array/IGCObject_DArray.hpp index d2b4f34..4854eff 100644 --- a/include/xo/object2/array/IGCObject_DArray.hpp +++ b/include/xo/object2/array/IGCObject_DArray.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DArray & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DArray & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DArray & self, obj mm) 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 9afd964..c437f0b 100644 --- a/include/xo/object2/boolean/IGCObject_DBoolean.hpp +++ b/include/xo/object2/boolean/IGCObject_DBoolean.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DBoolean & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DBoolean & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DBoolean & self, obj mm) 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 3682f09..323afd6 100644 --- a/include/xo/object2/dictionary/IGCObject_DDictionary.hpp +++ b/include/xo/object2/dictionary/IGCObject_DDictionary.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DDictionary & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DDictionary & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DDictionary & self, obj mm) 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 3bb4d3d..f09be05 100644 --- a/include/xo/object2/error/IGCObject_DRuntimeError.hpp +++ b/include/xo/object2/error/IGCObject_DRuntimeError.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DRuntimeError & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DRuntimeError & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DRuntimeError & self, obj mm) 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 7e1f142..e601ce0 100644 --- a/include/xo/object2/list/IGCObject_DList.hpp +++ b/include/xo/object2/list/IGCObject_DList.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DList & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DList & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DList & self, obj mm) 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 e62d14d..f9040b1 100644 --- a/include/xo/object2/number/IGCObject_DFloat.hpp +++ b/include/xo/object2/number/IGCObject_DFloat.hpp @@ -51,10 +51,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DFloat & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DFloat & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DFloat & self, obj mm) 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 f273707..b653212 100644 --- a/include/xo/object2/number/IGCObject_DInteger.hpp +++ b/include/xo/object2/number/IGCObject_DInteger.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DInteger & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DInteger & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DInteger & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DInteger & self, obj gc) noexcept; ///@} diff --git a/include/xo/object2/sequence/ASequence.hpp b/include/xo/object2/sequence/ASequence.hpp index 44f1d1c..fcb272b 100644 --- a/include/xo/object2/sequence/ASequence.hpp +++ b/include/xo/object2/sequence/ASequence.hpp @@ -49,6 +49,11 @@ public: /** @defgroup scm-sequence-methods **/ ///@{ // const methods + /** An uninitialized ASequence instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ diff --git a/src/object2/DDictionary.cpp b/src/object2/DDictionary.cpp index d585ded..263ea97 100644 --- a/src/object2/DDictionary.cpp +++ b/src/object2/DDictionary.cpp @@ -274,7 +274,7 @@ namespace xo { } DDictionary * - DDictionary::shallow_copy(obj mm) const noexcept + DDictionary::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index b9ac058..6f93147 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -185,7 +185,7 @@ namespace xo { } DList * - DList::shallow_copy(obj mm) const noexcept + DList::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/object2/IGCObject_DArray.cpp b/src/object2/IGCObject_DArray.cpp index 1063bd4..9b28a3d 100644 --- a/src/object2/IGCObject_DArray.cpp +++ b/src/object2/IGCObject_DArray.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DArray::shallow_copy(const DArray & self, obj mm) noexcept -> Opaque + IGCObject_DArray::shallow_copy(DArray & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 3ef60ae..e6bd600 100644 --- a/src/object2/IGCObject_DBoolean.cpp +++ b/src/object2/IGCObject_DBoolean.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DBoolean::shallow_copy(const DBoolean & self, obj mm) noexcept -> Opaque + IGCObject_DBoolean::shallow_copy(DBoolean & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 a6705d9..0466edd 100644 --- a/src/object2/IGCObject_DDictionary.cpp +++ b/src/object2/IGCObject_DDictionary.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DDictionary::shallow_copy(const DDictionary & self, obj mm) noexcept -> Opaque + IGCObject_DDictionary::shallow_copy(DDictionary & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 9e31cf6..4b1ab56 100644 --- a/src/object2/IGCObject_DFloat.cpp +++ b/src/object2/IGCObject_DFloat.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DFloat::shallow_copy(const DFloat & self, obj mm) noexcept -> Opaque + IGCObject_DFloat::shallow_copy(DFloat & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 55e1fae..fbb3190 100644 --- a/src/object2/IGCObject_DInteger.cpp +++ b/src/object2/IGCObject_DInteger.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DInteger::shallow_copy(const DInteger & self, obj mm) noexcept -> Opaque + IGCObject_DInteger::shallow_copy(DInteger & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 f4e9472..80cd7cd 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DList::shallow_copy(const DList & self, obj mm) noexcept -> Opaque + IGCObject_DList::shallow_copy(DList & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - 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 d44c435..6d16781 100644 --- a/src/object2/IGCObject_DRuntimeError.cpp +++ b/src/object2/IGCObject_DRuntimeError.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DRuntimeError::shallow_copy(const DRuntimeError & self, obj mm) noexcept -> Opaque + IGCObject_DRuntimeError::shallow_copy(DRuntimeError & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj gc) noexcept -> size_type {