refactor: use GCObjectVisitor api w/ gco_shallow_move

This commit is contained in:
Roland Conybeare 2026-04-06 15:21:48 -04:00
commit 7d3d2d7070
8 changed files with 16 additions and 22 deletions

View file

@ -6,7 +6,7 @@
#pragma once
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/Collector.hpp>
//#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -47,7 +47,7 @@ namespace xo {
/** xo allocator **/
using AAllocator = xo::mm::AAllocator;
/** garbage collector **/
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
/** object visitor (garbage collector proxy) **/
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
/** ppindentinfo for APrintable **/
@ -245,10 +245,8 @@ namespace xo {
/** @defgroup dstring-gcobject-methods gcobject facet methods **/
///@{
size_type shallow_size() const noexcept;
/** clone string, using memory from allocator @p mm **/
DString * shallow_move(obj<ACollector> gc) noexcept;
DString * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** fixup child pointers (trivial for DString, no children)
* note: cref so we can use forward decl

View file

@ -90,7 +90,7 @@ namespace xo {
///@{
/** clone unique string, using memory from allocator @p mm. **/
DUniqueString * shallow_move(obj<ACollector> gc) noexcept;
DUniqueString * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** fixup child pointers (trivial for DUniqueString, no gc-owned children **/
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;

View file

@ -53,8 +53,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DString & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DString & self, obj<AGCObjectVisitor> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/

View file

@ -53,8 +53,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DUniqueString & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DUniqueString & self, obj<AGCObjectVisitor> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/