collect lua garbage before starter destroy. register sol ptrs.

This commit is contained in:
2019-10-12 07:38:17 +07:00
parent 9633edd1d0
commit ebbbd896d4
4 changed files with 61 additions and 1 deletions

View File

@@ -75,6 +75,10 @@ namespace e2d
class atlas;
class flipbook;
class gobject;
template < typename T >
class gcomponent;
template < typename T >
class const_gcomponent;
class model;
class node;
class prefab;
@@ -86,3 +90,51 @@ namespace e2d
class starter;
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();
}
};
}

View File

@@ -17,6 +17,8 @@ namespace e2d
luasol();
~luasol() noexcept final = default;
void collect_garbage();
template < typename F >
decltype(auto) with_state(F&& f);
template < typename F >