Function reset

Synopsis

#include <src/entt/meta/meta.hpp>

void reset() noexcept

Description

Resets a meta type and all its parts.

This function resets a meta type and all its data members, member functions and properties, as well as its constructors, destructors and conversion functions if any.
Base classes aren't reset but the link between the two types is removed.

The meta type is also removed from the list of searchable types.

Source

Lines 1470-1501 in src/entt/meta/meta.hpp.

void reset() ENTT_NOEXCEPT {
    auto** it = internal::meta_context::global();
    while (*it && *it != node) {
        it = &(*it)->next;
    }
    if(*it) {
        *it = (*it)->next;
    }
    const auto unregister_all = y_combinator{
        [](auto &&self, auto **curr, auto... member) {
            while(*curr) {
                auto *prev = *curr;
                (self(&(prev->*member)), ...);
                *curr = prev->next;
                prev->next = nullptr;
            }
        }
    };
    unregister_all(&node->prop);
    unregister_all(&node->base);
    unregister_all(&node->conv);
    unregister_all(&node->ctor, &internal::meta_ctor_node::prop);
    unregister_all(&node->data, &internal::meta_data_node::prop);
    unregister_all(&node->func, &internal::meta_func_node::prop);
    node->id = {};
    node->dtor = nullptr;
}





Add Discussion

Log in to comment