refactor: use GCObjectVisitor api w/ gco_shallow_move

This commit is contained in:
Roland Conybeare 2026-04-06 15:21:48 -04:00
commit 6188b6398b
15 changed files with 32 additions and 24 deletions

View file

@ -76,7 +76,7 @@ namespace xo {
using FunctionPtrType = Fn;
using Traits = detail::PmFnTraits<Fn>;
using ACollector = xo::mm::ACollector;
//using ACollector = xo::mm::ACollector;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
@ -135,7 +135,7 @@ namespace xo {
///@}
/** @defgroup scm-primitive-gcobject-facet **/
///@{
Primitive * shallow_move(obj<ACollector> gc) noexcept;
Primitive * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
@ -193,7 +193,7 @@ namespace xo {
template <typename Fn>
Primitive<Fn> *
Primitive<Fn>::shallow_move(obj<ACollector> gc) noexcept {
Primitive<Fn>::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept {
return gc.std_move_for(this);
}

View file

@ -16,6 +16,7 @@
// includes (via {facet_includes})
#include <xo/stringtable2/StringTable.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/arena/MemorySizeInfo.hpp>
#include <xo/facet/obj.hpp>
#include <xo/facet/facet_implementation.hpp>

View file

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

@ -15,6 +15,7 @@
#include <xo/stringtable2/StringTable.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/arena/MemorySizeInfo.hpp>
namespace xo {