diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index a349ea9d..775e7bc7 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2017-06-13 20:34:08.313723 UTC -// This header was generated with sol v2.17.5 (revision 51a03b2) +// Generated 2017-06-15 05:24:30.745677 UTC +// This header was generated with sol v2.17.5 (revision 0fb5333) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -4447,25 +4447,26 @@ namespace sol { template struct as_value_tag {}; - using special_destruct_func = void(*)(void*); - - template - inline void special_destruct(void* memory) { - T** pointerpointer = static_cast(memory); - special_destruct_func* dx = static_cast(static_cast(pointerpointer + 1)); - Real* target = static_cast(static_cast(dx + 1)); - target->~Real(); - } + using unique_destructor = void(*)(void*); template inline int unique_destruct(lua_State* L) { void* memory = lua_touserdata(L, 1); T** pointerpointer = static_cast(memory); - special_destruct_func& dx = *static_cast(static_cast(pointerpointer + 1)); + unique_destructor& dx = *static_cast(static_cast(pointerpointer + 1)); (dx)(memory); return 0; } + template + inline void usertype_unique_alloc_destroy(void* memory) { + T** pointerpointer = static_cast(memory); + unique_destructor* dx = static_cast(static_cast(pointerpointer + 1)); + Real* target = static_cast(static_cast(dx + 1)); + std::allocator alloc; + alloc.destroy(target); + } + template inline int user_alloc_destroy(lua_State* L) { void* rawdata = lua_touserdata(L, 1); @@ -5497,8 +5498,16 @@ namespace sol { return true; } int metatableindex = lua_gettop(L); - if (stack_detail::check_metatable>(L, metatableindex)) - return true; + if (stack_detail::check_metatable>(L, metatableindex)) { + void* memory = lua_touserdata(L, 1); + T** pointerpointer = static_cast(memory); + detail::unique_destructor& pdx = *static_cast(static_cast(pointerpointer + 1)); + bool success = &detail::usertype_unique_alloc_destroy == pdx; + if (!success) { + handler(L, index, type::userdata, indextype); + } + return success; + } lua_pop(L, 1); handler(L, index, type::userdata, indextype); return false; @@ -6110,7 +6119,7 @@ namespace sol { static Real& get(lua_State* L, int index, record& tracking) { tracking.use(1); P** pref = static_cast(lua_touserdata(L, index)); - detail::special_destruct_func* fx = static_cast(static_cast(pref + 1)); + detail::unique_destructor* fx = static_cast(static_cast(pref + 1)); Real* mem = static_cast(static_cast(fx + 1)); return *mem; } @@ -6472,10 +6481,10 @@ namespace sol { template static int push_deep(lua_State* L, Args&&... args) { - P** pref = static_cast(lua_newuserdata(L, sizeof(P*) + sizeof(detail::special_destruct_func) + sizeof(Real))); - detail::special_destruct_func* fx = static_cast(static_cast(pref + 1)); + P** pref = static_cast(lua_newuserdata(L, sizeof(P*) + sizeof(detail::unique_destructor) + sizeof(Real))); + detail::unique_destructor* fx = static_cast(static_cast(pref + 1)); Real* mem = static_cast(static_cast(fx + 1)); - *fx = detail::special_destruct; + *fx = detail::usertype_unique_alloc_destroy; detail::default_construct::construct(mem, std::forward(args)...); *pref = unique_usertype_traits::get(*mem); if (luaL_newmetatable(L, &usertype_traits>::metatable()[0]) == 1) { @@ -11458,8 +11467,8 @@ namespace sol { bool hasdestructor = !value_table.empty() && to_string(meta_function::garbage_collect) == value_table[lastreg - 1].name; if (hasdestructor) { ref_table[lastreg - 1] = { nullptr, nullptr }; - unique_table[lastreg - 1] = { value_table[lastreg - 1].name, detail::unique_destruct }; } + unique_table[lastreg - 1] = { value_table[lastreg - 1].name, detail::unique_destruct }; // Now use um const bool& mustindex = umc.mustindex;