diff --git a/sol/inheritance.hpp b/sol/inheritance.hpp index 9c0cad75..cd452636 100644 --- a/sol/inheritance.hpp +++ b/sol/inheritance.hpp @@ -116,6 +116,7 @@ namespace sol { static int type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) { typedef unique_usertype_traits uu_traits; typedef typename uu_traits::template rebind_base rebind_t; + typedef std::conditional_t::value, types<>, bases_t> cond_bases_t; string_view this_rebind_ti = usertype_traits::qualified_name(); if (rebind_ti != this_rebind_ti) { // this is not even of the same unique type @@ -123,10 +124,10 @@ namespace sol { } string_view this_ti = usertype_traits::qualified_name(); if (ti == this_ti) { - // + // direct match, return 1 return 1; } - return type_unique_cast_bases(bases_t(), source_data, target_data, ti); + return type_unique_cast_bases(cond_bases_t(), source_data, target_data, ti); } }; @@ -137,6 +138,6 @@ namespace sol { } // namespace sol #define SOL_BASE_CLASSES(T, ...) template <> struct ::sol::base : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; }; -//#define SOL_DERIVED_CLASSES(T, ...) template <> struct ::sol::derive : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; }; +#define SOL_DERIVED_CLASSES(T, ...) template <> struct ::sol::derive : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; }; #endif // SOL_INHERITANCE_HPP diff --git a/sol/stack_core.hpp b/sol/stack_core.hpp index 70853d7e..f0962555 100644 --- a/sol/stack_core.hpp +++ b/sol/stack_core.hpp @@ -447,9 +447,7 @@ namespace sol { void* memory = lua_touserdata(L, 1); memory = align_usertype_unique_destructor(memory); unique_destructor& dx = *static_cast(memory); - memory = static_cast(static_cast(memory) + sizeof(unique_destructor)); memory = align_usertype_unique_tag(memory); - memory = static_cast(static_cast(memory) + sizeof(unique_tag)); (dx)(memory); return 0; } diff --git a/sol/stack_get_qualified.hpp b/sol/stack_get_qualified.hpp index d5e765fd..78d9b4a0 100644 --- a/sol/stack_get_qualified.hpp +++ b/sol/stack_get_qualified.hpp @@ -33,6 +33,7 @@ namespace stack { struct qualified_getter::value && is_unique_usertype>::value + && !std::is_void>::template rebind_base>::value >> { typedef unique_usertype_traits> u_traits; typedef typename u_traits::type T; diff --git a/sol/stack_push.hpp b/sol/stack_push.hpp index 0f3541f9..16225005 100644 --- a/sol/stack_push.hpp +++ b/sol/stack_push.hpp @@ -144,8 +144,10 @@ namespace stack { template struct pusher::value>> { - typedef typename unique_usertype_traits::type P; - typedef typename unique_usertype_traits::actual_type Real; + typedef unique_usertype_traits u_traits; + typedef typename u_traits::type P; + typedef typename u_traits::actual_type Real; + typedef typename u_traits::template rebind_base rebind_t; template >> = meta::enabler> static int push(lua_State* L, Arg&& arg) {