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

@ -62,10 +62,10 @@
// },
],
nonconst_methods: [
// Opaque shallow_move(obj<AAllocator>>) noexcept
// Opaque shallow_move(obj<ACollector>) noexcept
{
name: "shallow_move",
doc: ["move instance using allocator"],
doc: ["move instance using collector"],
return_type: "Opaque",
args:[
{type: "obj<ACollector>", name: "gc"},

View file

@ -57,6 +57,22 @@
// },
],
nonconst_methods: [
// void alloc_copy(void * src)
{
name: "alloc_copy",
doc: [
"allocate copy of source object at address @p src.",
"Source must be owned by this collector.",
"Increments object age"
],
return_type: "void *",
args: [
{type: "std::byte *", name: "src"},
],
const: false,
noexcept: false,
attributes: [],
},
// void visit_child(AGCObject * iface, void ** pp_data) noexcept;
{
name: "visit_child",

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);
}

View file

@ -35,6 +35,12 @@ IGCObjectVisitor_Any::_valid
// nonconst methods
auto
IGCObjectVisitor_Any::alloc_copy(Opaque, std::byte *) -> void *
{
_fatal();
}
auto
IGCObjectVisitor_Any::visit_child(Opaque, AGCObject *, void **) const noexcept -> void
{