refactor: make AGCObject.shallow_copy() non-const

prep for moving to ACollector interface
This commit is contained in:
Roland Conybeare 2026-04-04 14:38:14 -04:00
commit 24f857588c
19 changed files with 30 additions and 32 deletions

View file

@ -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<AAllocator> mm) const noexcept;
DDictionary * shallow_copy(obj<AAllocator> mm) noexcept;
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
AAllocator::size_type forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -70,7 +70,7 @@ namespace xo {
/** @defgroup xo-scm-list-gcobject-facet gcobject facet **/
///@{
size_type shallow_size() const noexcept;
DList * shallow_copy(obj<AAllocator> mm) const noexcept;
DList * shallow_copy(obj<AAllocator> mm) noexcept;
size_type forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DArray & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DArray & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DBoolean & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DBoolean & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DDictionary & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DDictionary & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DRuntimeError & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DRuntimeError & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DList & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DList & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DFloat & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DFloat & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AAllocator> mm) noexcept;
// non-const methods
/** copy instance using allocator **/
static Opaque shallow_copy(DInteger & self, obj<AAllocator> mm) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DInteger & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -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<AFacet> will have non-null vtable (via IFacet_Any) with all methods terminating.
**/
bool _has_null_vptr() const noexcept { return *reinterpret_cast<const void * const *>(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 **/

View file

@ -274,7 +274,7 @@ namespace xo {
}
DDictionary *
DDictionary::shallow_copy(obj<AAllocator> mm) const noexcept
DDictionary::shallow_copy(obj<AAllocator> mm) noexcept
{
return mm.std_copy_for(this);
}

View file

@ -185,7 +185,7 @@ namespace xo {
}
DList *
DList::shallow_copy(obj<AAllocator> mm) const noexcept
DList::shallow_copy(obj<AAllocator> mm) noexcept
{
return mm.std_copy_for(this);
}

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DArray::shallow_copy(const DArray & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DArray::shallow_copy(DArray & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DArray::forward_children(DArray & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DBoolean::shallow_copy(const DBoolean & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DBoolean::shallow_copy(DBoolean & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DBoolean::forward_children(DBoolean & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DDictionary::shallow_copy(const DDictionary & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DDictionary::shallow_copy(DDictionary & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DDictionary::forward_children(DDictionary & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DFloat::shallow_copy(const DFloat & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DFloat::shallow_copy(DFloat & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DFloat::forward_children(DFloat & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DInteger::shallow_copy(const DInteger & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DInteger::shallow_copy(DInteger & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DInteger::forward_children(DInteger & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DList::shallow_copy(const DList & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DList::shallow_copy(DList & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DList::forward_children(DList & self, obj<ACollector> gc) noexcept -> size_type
{

View file

@ -22,11 +22,10 @@ namespace xo {
}
auto
IGCObject_DRuntimeError::shallow_copy(const DRuntimeError & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DRuntimeError::shallow_copy(DRuntimeError & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DRuntimeError::forward_children(DRuntimeError & self, obj<ACollector> gc) noexcept -> size_type
{