Use ComponentRc during item tree traversal

This is in preparation for allowing the run-time / items to clone VRc's
of the component.

ComponentVTable functions like visit_children_item contine to take a
ComponentRefPin as "self" parameter type, as a VRc would not be
supported by rust right now. That means the implementation then uses
self_weak to obtain a strong self-reference.
This commit is contained in:
Simon Hausmann 2020-11-12 15:49:02 +01:00
parent 54cc66c400
commit 78fae068dd
9 changed files with 72 additions and 49 deletions

View file

@ -74,6 +74,8 @@ private:
X data;
Layout layout;
};
void *data_ptr() { return reinterpret_cast<char *>(this) + data_offset; }
};
struct Dyn {};
@ -120,6 +122,8 @@ public:
}
VRc<VTable, Dyn> into_dyn() const { return *reinterpret_cast<const VRc<VTable, Dyn> *>(this); }
VRef<VTable> borrow() const { return { inner->vtable, inner->data_ptr() }; }
};
template<typename VTable, typename X = Dyn>