refactor: use GCObjectVisitor api w/ gco_shallow_move

This commit is contained in:
Roland Conybeare 2026-04-06 15:21:48 -04:00
commit 21ce28ee82
28 changed files with 59 additions and 51 deletions

View file

@ -6,7 +6,7 @@
#pragma once
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/Collector.hpp>
//#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -33,7 +33,7 @@ namespace xo {
/** xo allocator facet **/
using AAllocator = xo::mm::AAllocator;
/** garbage collector facet **/
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
/** gc-aware object facet **/
using AGCObject = xo::mm::AGCObject;
/** gc-centric object visitor **/
@ -148,7 +148,7 @@ namespace xo {
/** @defgroup darray-gcobject-methods **/
///@{
/** move to new address, mandated by @p gc **/
DArray * shallow_move(obj<ACollector> gc) noexcept;
DArray * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -5,7 +5,7 @@
#pragma once
#include <xo/alloc2/Collector.hpp>
//#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -16,7 +16,7 @@ namespace xo {
namespace scm {
struct DBoolean {
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using ppindentinfo = xo::print::ppindentinfo;
@ -39,7 +39,7 @@ namespace xo {
// GCObject facet
DBoolean * shallow_move(obj<ACollector> gc) noexcept;
DBoolean * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
private:

View file

@ -204,7 +204,7 @@ namespace xo {
/** @defgroup ddictionary-gcobject-methods **/
///@{
/** return shallow copy of this array, using memory from @p mm **/
DDictionary * shallow_move(obj<ACollector> gc) noexcept;
DDictionary * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** forward elements to @p gc to-space; replace originals with forwarding pointers **/
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

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>
@ -15,7 +15,7 @@ namespace xo {
namespace scm {
struct DFloat {
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using ppindentinfo = xo::print::ppindentinfo;
using value_type = double;
@ -36,7 +36,7 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
// GCObject facet
DFloat * shallow_move(obj<ACollector> gc) noexcept;
DFloat * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
private:

View file

@ -5,7 +5,7 @@
#pragma once
#include <xo/alloc2/Collector.hpp>
//#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -16,7 +16,7 @@ namespace xo {
namespace scm {
struct DInteger {
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using ppindentinfo = xo::print::ppindentinfo;
@ -41,7 +41,7 @@ namespace xo {
// GCObject facet
DInteger * shallow_move(obj<ACollector> gc) noexcept;
DInteger * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
private:

View file

@ -5,6 +5,7 @@
#pragma once
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -70,7 +71,7 @@ namespace xo {
/** @defgroup xo-scm-list-gcobject-facet gcobject facet **/
///@{
DList * shallow_move(obj<ACollector> gc) noexcept;
DList * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -17,7 +17,7 @@ namespace xo {
class DRuntimeError {
public:
using AGCObject = xo::mm::AGCObject;
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using ppindentinfo = xo::print::ppindentinfo;
@ -50,7 +50,7 @@ namespace xo {
/** @defgroup scm-runtimeerror-gcobject-facet gcobject facet **/
///@{
DRuntimeError * shallow_move(obj<ACollector> gc) noexcept;
DRuntimeError * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DArray & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DArray & 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

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DBoolean & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DBoolean & 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

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DDictionary & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DDictionary & 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

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DRuntimeError & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DRuntimeError & 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

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DList & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DList & 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

@ -52,8 +52,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DFloat & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DFloat & 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

@ -51,8 +51,9 @@ namespace xo {
// const methods
// non-const methods
/** move instance using collector **/
static Opaque shallow_move(DInteger & self, obj<ACollector> gc) noexcept;
/** move instance using object visitor.
Arguably abusing the word 'visitor' here **/
static Opaque gco_shallow_move(DInteger & 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 **/