mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
clean up interactions with unique types that are not base/derived aliasing
This commit is contained in:
parent
96143d8d79
commit
8b52c35249
|
@ -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) {
|
static int type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
|
||||||
typedef unique_usertype_traits<U> uu_traits;
|
typedef unique_usertype_traits<U> uu_traits;
|
||||||
typedef typename uu_traits::template rebind_base<void> rebind_t;
|
typedef typename uu_traits::template rebind_base<void> rebind_t;
|
||||||
|
typedef std::conditional_t<std::is_void<rebind_t>::value, types<>, bases_t> cond_bases_t;
|
||||||
string_view this_rebind_ti = usertype_traits<rebind_t>::qualified_name();
|
string_view this_rebind_ti = usertype_traits<rebind_t>::qualified_name();
|
||||||
if (rebind_ti != this_rebind_ti) {
|
if (rebind_ti != this_rebind_ti) {
|
||||||
// this is not even of the same unique type
|
// this is not even of the same unique type
|
||||||
|
@ -123,10 +124,10 @@ namespace sol {
|
||||||
}
|
}
|
||||||
string_view this_ti = usertype_traits<T>::qualified_name();
|
string_view this_ti = usertype_traits<T>::qualified_name();
|
||||||
if (ti == this_ti) {
|
if (ti == this_ti) {
|
||||||
//
|
// direct match, return 1
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return type_unique_cast_bases<U>(bases_t(), source_data, target_data, ti);
|
return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -137,6 +138,6 @@ namespace sol {
|
||||||
} // namespace sol
|
} // namespace sol
|
||||||
|
|
||||||
#define SOL_BASE_CLASSES(T, ...) template <> struct ::sol::base<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
|
#define SOL_BASE_CLASSES(T, ...) template <> struct ::sol::base<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
|
||||||
//#define SOL_DERIVED_CLASSES(T, ...) template <> struct ::sol::derive<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
|
#define SOL_DERIVED_CLASSES(T, ...) template <> struct ::sol::derive<T> : ::std::true_type { typedef ::sol::types<__VA_ARGS__> type; };
|
||||||
|
|
||||||
#endif // SOL_INHERITANCE_HPP
|
#endif // SOL_INHERITANCE_HPP
|
||||||
|
|
|
@ -447,9 +447,7 @@ namespace sol {
|
||||||
void* memory = lua_touserdata(L, 1);
|
void* memory = lua_touserdata(L, 1);
|
||||||
memory = align_usertype_unique_destructor(memory);
|
memory = align_usertype_unique_destructor(memory);
|
||||||
unique_destructor& dx = *static_cast<unique_destructor*>(memory);
|
unique_destructor& dx = *static_cast<unique_destructor*>(memory);
|
||||||
memory = static_cast<void*>(static_cast<char*>(memory) + sizeof(unique_destructor));
|
|
||||||
memory = align_usertype_unique_tag<true>(memory);
|
memory = align_usertype_unique_tag<true>(memory);
|
||||||
memory = static_cast<void*>(static_cast<char*>(memory) + sizeof(unique_tag));
|
|
||||||
(dx)(memory);
|
(dx)(memory);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace stack {
|
||||||
struct qualified_getter<X, std::enable_if_t<
|
struct qualified_getter<X, std::enable_if_t<
|
||||||
!std::is_reference<X>::value
|
!std::is_reference<X>::value
|
||||||
&& is_unique_usertype<meta::unqualified_t<X>>::value
|
&& is_unique_usertype<meta::unqualified_t<X>>::value
|
||||||
|
&& !std::is_void<typename unique_usertype_traits<meta::unqualified_t<X>>::template rebind_base<void>>::value
|
||||||
>> {
|
>> {
|
||||||
typedef unique_usertype_traits<meta::unqualified_t<X>> u_traits;
|
typedef unique_usertype_traits<meta::unqualified_t<X>> u_traits;
|
||||||
typedef typename u_traits::type T;
|
typedef typename u_traits::type T;
|
||||||
|
|
|
@ -144,8 +144,10 @@ namespace stack {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct pusher<T, std::enable_if_t<is_unique_usertype<T>::value>> {
|
struct pusher<T, std::enable_if_t<is_unique_usertype<T>::value>> {
|
||||||
typedef typename unique_usertype_traits<T>::type P;
|
typedef unique_usertype_traits<T> u_traits;
|
||||||
typedef typename unique_usertype_traits<T>::actual_type Real;
|
typedef typename u_traits::type P;
|
||||||
|
typedef typename u_traits::actual_type Real;
|
||||||
|
typedef typename u_traits::template rebind_base<void> rebind_t;
|
||||||
|
|
||||||
template <typename Arg, meta::enable<std::is_base_of<Real, meta::unqualified_t<Arg>>> = meta::enabler>
|
template <typename Arg, meta::enable<std::is_base_of<Real, meta::unqualified_t<Arg>>> = meta::enabler>
|
||||||
static int push(lua_State* L, Arg&& arg) {
|
static int push(lua_State* L, Arg&& arg) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user