Put the CompoentType inside the class in the generated code

and start working on safe wrapper
This commit is contained in:
Olivier Goffart 2020-05-07 10:36:23 +02:00
parent bdaf14ae23
commit 2f16517291
3 changed files with 89 additions and 23 deletions

View file

@ -7,14 +7,18 @@ namespace sixtyfps {
using internal::ItemTreeNode;
using internal::ComponentType;
template<typename Component> void run(Component *c, const ComponentType *t) {
template<typename Component> void run(Component *c) {
// FIXME! some static assert that the component is indeed a generated component matching
// the vtable. In fact, i think the VTable should be a static member of the Component
internal::sixtyfps_runtime_run_component(t, reinterpret_cast<internal::ComponentImpl *>(c));
internal::sixtyfps_runtime_run_component(&Component::component_type, reinterpret_cast<internal::ComponentImpl *>(c));
}
using internal::Rectangle;
using internal::RectangleVTable;
using internal::Image;
using internal::ImageVTable;
// the component has static lifetime so it does not need to be destroyed
// FIXME: we probably need some kind of way to dinstinguish static component and these on the heap
inline void dummy_destory(const ComponentType *, internal::ComponentImpl *) {}
}