mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 22:16:53 +07:00
collect lua garbage before starter destroy. register sol ptrs.
This commit is contained in:
@@ -75,6 +75,10 @@ namespace e2d
|
|||||||
class atlas;
|
class atlas;
|
||||||
class flipbook;
|
class flipbook;
|
||||||
class gobject;
|
class gobject;
|
||||||
|
template < typename T >
|
||||||
|
class gcomponent;
|
||||||
|
template < typename T >
|
||||||
|
class const_gcomponent;
|
||||||
class model;
|
class model;
|
||||||
class node;
|
class node;
|
||||||
class prefab;
|
class prefab;
|
||||||
@@ -86,3 +90,51 @@ namespace e2d
|
|||||||
class starter;
|
class starter;
|
||||||
class world;
|
class world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template < typename T >
|
||||||
|
struct unique_usertype_traits<e2d::intrusive_ptr<T>> {
|
||||||
|
using type = T;
|
||||||
|
using actual_type = e2d::intrusive_ptr<T>;
|
||||||
|
static const bool value = true;
|
||||||
|
|
||||||
|
static bool is_null(const actual_type& ptr) {
|
||||||
|
return !ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static type* get(actual_type& ptr) {
|
||||||
|
return ptr.get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
struct unique_usertype_traits<e2d::gcomponent<T>> {
|
||||||
|
using type = T;
|
||||||
|
using actual_type = e2d::gcomponent<T>;
|
||||||
|
static const bool value = true;
|
||||||
|
|
||||||
|
static bool is_null(const actual_type& ptr) {
|
||||||
|
return !ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static type* get(actual_type& ptr) {
|
||||||
|
return ptr.find();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < typename T >
|
||||||
|
struct unique_usertype_traits<e2d::const_gcomponent<T>> {
|
||||||
|
using type = T;
|
||||||
|
using actual_type = e2d::const_gcomponent<T>;
|
||||||
|
static const bool value = true;
|
||||||
|
|
||||||
|
static bool is_null(const actual_type& ptr) {
|
||||||
|
return !ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static type* get(actual_type& ptr) {
|
||||||
|
return ptr.find();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace e2d
|
|||||||
luasol();
|
luasol();
|
||||||
~luasol() noexcept final = default;
|
~luasol() noexcept final = default;
|
||||||
|
|
||||||
|
void collect_garbage();
|
||||||
|
|
||||||
template < typename F >
|
template < typename F >
|
||||||
decltype(auto) with_state(F&& f);
|
decltype(auto) with_state(F&& f);
|
||||||
template < typename F >
|
template < typename F >
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ namespace e2d
|
|||||||
bindings::bind_high(state_);
|
bindings::bind_high(state_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void luasol::collect_garbage() {
|
||||||
|
state_.collect_garbage();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<script> luasol::load_script(buffer_view src) {
|
std::optional<script> luasol::load_script(buffer_view src) {
|
||||||
E2D_ASSERT(is_in_main_thread());
|
E2D_ASSERT(is_in_main_thread());
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ namespace
|
|||||||
bool initialize() final {
|
bool initialize() final {
|
||||||
ecs::registry_filler(the<world>().registry())
|
ecs::registry_filler(the<world>().registry())
|
||||||
.system<flipbook_system>(world::priority_pre_update)
|
.system<flipbook_system>(world::priority_pre_update)
|
||||||
.system<label_system>(world::priority_pre_update)
|
|
||||||
.system<spine_pre_system>(world::priority_pre_update)
|
.system<spine_pre_system>(world::priority_pre_update)
|
||||||
.system<spine_post_system>(world::priority_post_update)
|
.system<spine_post_system>(world::priority_post_update)
|
||||||
|
.system<label_system>(world::priority_pre_render)
|
||||||
.system<render_system>(world::priority_render);
|
.system<render_system>(world::priority_render);
|
||||||
return !application_ || application_->initialize();
|
return !application_ || application_->initialize();
|
||||||
}
|
}
|
||||||
@@ -158,6 +158,8 @@ namespace e2d
|
|||||||
}
|
}
|
||||||
|
|
||||||
starter::~starter() noexcept {
|
starter::~starter() noexcept {
|
||||||
|
the<luasol>().collect_garbage();
|
||||||
|
|
||||||
modules::shutdown<world>();
|
modules::shutdown<world>();
|
||||||
modules::shutdown<library>();
|
modules::shutdown<library>();
|
||||||
modules::shutdown<factory>();
|
modules::shutdown<factory>();
|
||||||
|
|||||||
Reference in New Issue
Block a user