diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 57304cbd..1ad27ee9 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 2018-06-15 19:50:07.516271 UTC -// This header was generated with sol v2.20.2 (revision 2777b6a) +// Generated 2018-06-15 19:54:27.149295 UTC +// This header was generated with sol v2.20.2 (revision 92f3330) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -387,6 +387,11 @@ namespace sol { struct protect_t; template struct filter_wrapper; + + template + struct usertype_traits; + template + struct unique_usertype_traits; } // namespace sol // end of sol/forward.hpp @@ -6001,117 +6006,7 @@ namespace sol { // beginning of sol/inheritance.hpp -namespace sol { - template - struct base_list {}; - template - using bases = base_list; - - typedef bases<> base_classes_tag; - const auto base_classes = base_classes_tag(); - - namespace detail { - - template - struct has_derived { - static bool value; - }; - - template - bool has_derived::value = false; - - inline decltype(auto) base_class_check_key() { - static const auto& key = "class_check"; - return key; - } - - inline decltype(auto) base_class_cast_key() { - static const auto& key = "class_cast"; - return key; - } - - inline decltype(auto) base_class_index_propogation_key() { - static const auto& key = u8"\xF0\x9F\x8C\xB2.index"; - return key; - } - - inline decltype(auto) base_class_new_index_propogation_key() { - static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index"; - return key; - } - - template - struct inheritance { - static bool type_check_bases(types<>, const std::string&) { - return false; - } - - template - static bool type_check_bases(types, const std::string& ti) { - return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); - } - - static bool type_check(const std::string& ti) { - return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); - } - - static void* type_cast_bases(types<>, T*, const std::string&) { - return nullptr; - } - - template - static void* type_cast_bases(types, T* data, const std::string& ti) { - // Make sure to convert to T first, and then dynamic cast to the proper type - return ti != usertype_traits::qualified_name() ? type_cast_bases(types(), data, ti) : static_cast(static_cast(data)); - } - - static void* type_cast(void* voiddata, const std::string& ti) { - T* data = static_cast(voiddata); - return static_cast(ti != usertype_traits::qualified_name() ? type_cast_bases(types(), data, ti) : data); - } - - template - static bool type_unique_cast_bases(void*, const string_view&) { - return false; - } - - template - static bool type_unique_cast_bases(void* source_data, void* target_data, const string_view& ti) { - typedef unique_usertype_traits::typename rebind_base base_ptr; - string_view base_ti = usertype_traits::qualified_name(); - if (base_ti == ti) { - if (target_data != nullptr) { - U* source = static_cast(source_data); - base_ptr* target = static_cast(target_data); - // perform proper derived -> base conversion - *target = *source; - } - return true; - } - return type_unique_cast_bases(source_data, target_data, ti); - } - - template - static bool type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) { - typedef unique_usertype_traits::typename rebind_base rebind_t; - string_view this_rebind_ti = usertype_traits::qualified_name(); - if (rebind_ti != this_rebind_ti) { - // this is not even of the same container type - return false; - } - return type_unique_cast_bases(source_data, target_data, ti); - } - }; - - using inheritance_check_function = decltype(&inheritance::type_check); - using inheritance_cast_function = decltype(&inheritance::type_cast); - using inheritance_unique_cast_function = decltype(&inheritance::type_unique_cast); - } // namespace detail -} // namespace sol - -// end of sol/inheritance.hpp - -// beginning of sol/error_handler.hpp +// beginning of sol/usertype_traits.hpp // beginning of sol/demangle.hpp @@ -6259,6 +6154,152 @@ namespace detail { // end of sol/demangle.hpp +namespace sol { + + template + struct usertype_traits { + static const std::string& name() { + static const std::string& n = detail::short_demangle(); + return n; + } + static const std::string& qualified_name() { + static const std::string& q_n = detail::demangle(); + return q_n; + } + static const std::string& metatable() { + static const std::string m = std::string("sol.").append(detail::demangle()); + return m; + } + static const std::string& user_metatable() { + static const std::string u_m = std::string("sol.").append(detail::demangle()).append(".user"); + return u_m; + } + static const std::string& user_gc_metatable() { + static const std::string u_g_m = std::string("sol.").append(detail::demangle()).append(".user\xE2\x99\xBB"); + return u_g_m; + } + static const std::string& gc_table() { + static const std::string g_t = std::string("sol.").append(detail::demangle()).append(".\xE2\x99\xBB"); + return g_t; + } + }; + +} // namespace sol + +// end of sol/usertype_traits.hpp + +namespace sol { + template + struct base_list {}; + template + using bases = base_list; + + typedef bases<> base_classes_tag; + const auto base_classes = base_classes_tag(); + + namespace detail { + + template + struct has_derived { + static bool value; + }; + + template + bool has_derived::value = false; + + inline decltype(auto) base_class_check_key() { + static const auto& key = "class_check"; + return key; + } + + inline decltype(auto) base_class_cast_key() { + static const auto& key = "class_cast"; + return key; + } + + inline decltype(auto) base_class_index_propogation_key() { + static const auto& key = u8"\xF0\x9F\x8C\xB2.index"; + return key; + } + + inline decltype(auto) base_class_new_index_propogation_key() { + static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index"; + return key; + } + + template + struct inheritance { + static bool type_check_bases(types<>, const std::string&) { + return false; + } + + template + static bool type_check_bases(types, const std::string& ti) { + return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); + } + + static bool type_check(const std::string& ti) { + return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); + } + + static void* type_cast_bases(types<>, T*, const std::string&) { + return nullptr; + } + + template + static void* type_cast_bases(types, T* data, const std::string& ti) { + // Make sure to convert to T first, and then dynamic cast to the proper type + return ti != usertype_traits::qualified_name() ? type_cast_bases(types(), data, ti) : static_cast(static_cast(data)); + } + + static void* type_cast(void* voiddata, const std::string& ti) { + T* data = static_cast(voiddata); + return static_cast(ti != usertype_traits::qualified_name() ? type_cast_bases(types(), data, ti) : data); + } + + template + static bool type_unique_cast_bases(void*, const string_view&) { + return false; + } + + template + static bool type_unique_cast_bases(void* source_data, void* target_data, const string_view& ti) { + typedef unique_usertype_traits::typename rebind_base base_ptr; + string_view base_ti = usertype_traits::qualified_name(); + if (base_ti == ti) { + if (target_data != nullptr) { + U* source = static_cast(source_data); + base_ptr* target = static_cast(target_data); + // perform proper derived -> base conversion + *target = *source; + } + return true; + } + return type_unique_cast_bases(source_data, target_data, ti); + } + + template + static bool type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) { + typedef unique_usertype_traits::typename rebind_base rebind_t; + string_view this_rebind_ti = usertype_traits::qualified_name(); + if (rebind_ti != this_rebind_ti) { + // this is not even of the same container type + return false; + } + return type_unique_cast_bases(source_data, target_data, ti); + } + }; + + using inheritance_check_function = decltype(&inheritance::type_check); + using inheritance_cast_function = decltype(&inheritance::type_cast); + using inheritance_unique_cast_function = decltype(&inheritance::type_unique_cast); + } // namespace detail +} // namespace sol + +// end of sol/inheritance.hpp + +// beginning of sol/error_handler.hpp + namespace sol { inline std::string associated_type_name(lua_State* L, int index, type t) { @@ -8068,42 +8109,6 @@ namespace sol { // beginning of sol/stack_check_unqualified.hpp -// beginning of sol/usertype_traits.hpp - -namespace sol { - - template - struct usertype_traits { - static const std::string& name() { - static const std::string& n = detail::short_demangle(); - return n; - } - static const std::string& qualified_name() { - static const std::string& q_n = detail::demangle(); - return q_n; - } - static const std::string& metatable() { - static const std::string m = std::string("sol.").append(detail::demangle()); - return m; - } - static const std::string& user_metatable() { - static const std::string u_m = std::string("sol.").append(detail::demangle()).append(".user"); - return u_m; - } - static const std::string& user_gc_metatable() { - static const std::string u_g_m = std::string("sol.").append(detail::demangle()).append(".user\xE2\x99\xBB"); - return u_g_m; - } - static const std::string& gc_table() { - static const std::string g_t = std::string("sol.").append(detail::demangle()).append(".\xE2\x99\xBB"); - return g_t; - } - }; - -} // namespace sol - -// end of sol/usertype_traits.hpp - #include #ifdef SOL_CXX17_FEATURES #ifdef SOL_STD_VARIANT diff --git a/single/sol/sol_forward.hpp b/single/sol/sol_forward.hpp index c92748a0..47161dc6 100644 --- a/single/sol/sol_forward.hpp +++ b/single/sol/sol_forward.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 2018-06-15 19:50:08.054132 UTC -// This header was generated with sol v2.20.2 (revision 2777b6a) +// Generated 2018-06-15 19:54:27.490289 UTC +// This header was generated with sol v2.20.2 (revision 92f3330) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP @@ -354,6 +354,11 @@ namespace sol { struct protect_t; template struct filter_wrapper; + + template + struct usertype_traits; + template + struct unique_usertype_traits; } // namespace sol // end of sol/forward.hpp diff --git a/sol/forward.hpp b/sol/forward.hpp index ed14352c..dc5758fa 100644 --- a/sol/forward.hpp +++ b/sol/forward.hpp @@ -153,6 +153,11 @@ namespace sol { struct protect_t; template struct filter_wrapper; + + template + struct usertype_traits; + template + struct unique_usertype_traits; } // namespace sol #endif // SOL_FORWARD_HPP diff --git a/sol/inheritance.hpp b/sol/inheritance.hpp index 8c90f6eb..95320be7 100644 --- a/sol/inheritance.hpp +++ b/sol/inheritance.hpp @@ -25,6 +25,7 @@ #define SOL_INHERITANCE_HPP #include "types.hpp" +#include "usertype_traits.hpp" namespace sol { template