refactor: make shallow_move() available from AGCObjectVisitor

This commit is contained in:
Roland Conybeare 2026-04-06 00:11:08 -04:00
commit db4ccfd911
8 changed files with 36 additions and 3 deletions

View file

@ -67,7 +67,7 @@ public:
virtual void _drop(Opaque d) const noexcept = 0;
// nonconst methods
/** move instance using allocator **/
/** move instance using collector **/
virtual Opaque shallow_move(Opaque data, obj<ACollector> gc) const noexcept = 0;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place

View file

@ -55,6 +55,10 @@ public:
virtual void _drop(Opaque d) const noexcept = 0;
// nonconst methods
/** allocate copy of source object at address @p src.
Source must be owned by this collector.
Increments object age **/
virtual void * alloc_copy(Opaque data, std::byte * src) = 0;
/** visit child of a gc-aware object. May update child in-place! **/
virtual void visit_child(Opaque data, AGCObject * iface, void ** pp_data) const noexcept = 0;
///@}

View file

@ -60,6 +60,7 @@ namespace mm {
// const methods
// nonconst methods
[[noreturn]] void * alloc_copy(Opaque, std::byte *) override;
[[noreturn]] void visit_child(Opaque, AGCObject *, void **) const noexcept override;
///@}

View file

@ -44,6 +44,9 @@ namespace mm {
// const methods
// non-const methods
void * alloc_copy(Opaque data, std::byte * src) override {
return I::alloc_copy(_dcast(data), src);
}
void visit_child(Opaque data, AGCObject * iface, void ** pp_data) const noexcept override {
return I::visit_child(_dcast(data), iface, pp_data);
}

View file

@ -74,6 +74,9 @@ public:
// const methods
// non-const methods (still const in router!)
void * alloc_copy(std::byte * src) {
return O::iface()->alloc_copy(O::data(), src);
}
void visit_child(AGCObject * iface, void ** pp_data) noexcept {
return O::iface()->visit_child(O::data(), iface, pp_data);
}