refactor: use GCObjectVisitor api w/ gco_shallow_move
This commit is contained in:
parent
ee521d3337
commit
21ce28ee82
28 changed files with 59 additions and 51 deletions
|
|
@ -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;
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -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 **/
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ namespace xo {
|
|||
// gc hooks for IGCObject_DArray
|
||||
|
||||
DArray *
|
||||
DArray::shallow_move(obj<ACollector> gc) noexcept
|
||||
DArray::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
// note: not using gc.std_move_for() here.
|
||||
// flexible array -> compiler doesn't know actual DArray allocation size
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
DBoolean *
|
||||
DBoolean::shallow_move(obj<ACollector> gc) noexcept
|
||||
DBoolean::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ namespace xo {
|
|||
// ----- gcobject facet -----
|
||||
|
||||
DDictionary *
|
||||
DDictionary::shallow_move(obj<ACollector> gc) noexcept
|
||||
DDictionary::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
DFloat *
|
||||
DFloat::shallow_move(obj<ACollector> gc) noexcept
|
||||
DFloat::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
DInteger *
|
||||
DInteger::shallow_move(obj<ACollector> gc) noexcept
|
||||
DInteger::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ namespace xo {
|
|||
// ----- GCObject facet ------
|
||||
|
||||
DList *
|
||||
DList::shallow_move(obj<ACollector> gc) noexcept
|
||||
DList::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace xo {
|
|||
// ----- GCObject facet -----
|
||||
|
||||
DRuntimeError *
|
||||
DRuntimeError::shallow_move(obj<ACollector> gc) noexcept
|
||||
DRuntimeError::gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DArray::shallow_move(DArray & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DArray::gco_shallow_move(DArray & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DArray::visit_gco_children(DArray & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DBoolean::shallow_move(DBoolean & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DBoolean::gco_shallow_move(DBoolean & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DBoolean::visit_gco_children(DBoolean & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DDictionary::shallow_move(DDictionary & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DDictionary::gco_shallow_move(DDictionary & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DDictionary::visit_gco_children(DDictionary & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DFloat::shallow_move(DFloat & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DFloat::gco_shallow_move(DFloat & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DFloat::visit_gco_children(DFloat & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DInteger::shallow_move(DInteger & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DInteger::gco_shallow_move(DInteger & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DInteger::visit_gco_children(DInteger & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DList::shallow_move(DList & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DList::gco_shallow_move(DList & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DList::visit_gco_children(DList & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
namespace xo {
|
||||
namespace scm {
|
||||
auto
|
||||
IGCObject_DRuntimeError::shallow_move(DRuntimeError & self, obj<ACollector> gc) noexcept -> Opaque
|
||||
IGCObject_DRuntimeError::gco_shallow_move(DRuntimeError & self, obj<AGCObjectVisitor> gc) noexcept -> Opaque
|
||||
{
|
||||
return self.shallow_move(gc);
|
||||
return self.gco_shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue