From bd3fe0cac583739bc0d7c4b5c8f301bb350abca0 Mon Sep 17 00:00:00 2001 From: Andy Belle-Isle Date: Fri, 30 Aug 2019 00:19:31 -0400 Subject: Renamed lib to deps so github will ignore it for language stats --- lib/sol2/include/sol/inheritance.hpp | 196 ----------------------------------- 1 file changed, 196 deletions(-) delete mode 100644 lib/sol2/include/sol/inheritance.hpp (limited to 'lib/sol2/include/sol/inheritance.hpp') diff --git a/lib/sol2/include/sol/inheritance.hpp b/lib/sol2/include/sol/inheritance.hpp deleted file mode 100644 index 6abe6ad..0000000 --- a/lib/sol2/include/sol/inheritance.hpp +++ /dev/null @@ -1,196 +0,0 @@ -// sol3 - -// The MIT License (MIT) - -// Copyright (c) 2013-2019 Rapptz, ThePhD and contributors - -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -#ifndef SOL_INHERITANCE_HPP -#define SOL_INHERITANCE_HPP - -#include "types.hpp" -#include "usertype_traits.hpp" -#include "unique_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(); - - template - struct is_to_stringable> : std::false_type {}; - - namespace detail { - - 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 { - typedef typename base::type bases_t; - - static bool type_check_bases(types<>, const string_view&) { - return false; - } - - template - static bool type_check_bases(types, const string_view& ti) { - return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); - } - - static bool type_check(const string_view& ti) { - return ti == usertype_traits::qualified_name() || type_check_bases(bases_t(), ti); - } - - template - static bool type_check_with(const string_view& ti) { - return ti == usertype_traits::qualified_name() || type_check_bases(types(), ti); - } - - static void* type_cast_bases(types<>, T*, const string_view&) { - return nullptr; - } - - template - static void* type_cast_bases(types, T* data, const string_view& 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 string_view& ti) { - T* data = static_cast(voiddata); - return static_cast(ti != usertype_traits::qualified_name() ? type_cast_bases(bases_t(), data, ti) : data); - } - - template - static void* type_cast_with(void* voiddata, const string_view& 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(types<>, void*, void*, const string_view&) { - return 0; - } - - template - static int type_unique_cast_bases(types, void* source_data, void* target_data, const string_view& ti) { - using uu_traits = unique_usertype_traits; - using base_ptr = typename uu_traits::template rebind_base; - 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 2; - } - return type_unique_cast_bases(types(), source_data, target_data, ti); - } - - template - 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; - if constexpr (is_base_rebindable_v) { - typedef typename uu_traits::template rebind_base rebind_t; - typedef meta::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 - return 0; - } - string_view this_ti = usertype_traits::qualified_name(); - if (ti == this_ti) { - // direct match, return 1 - return 1; - } - return type_unique_cast_bases(cond_bases_t(), source_data, target_data, ti); - } - else { - (void)rebind_ti; - string_view this_ti = usertype_traits::qualified_name(); - if (ti == this_ti) { - // direct match, return 1 - return 1; - } - return type_unique_cast_bases(types<>(), source_data, target_data, ti); - } - } - - template - static int type_unique_cast_with(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) { - using uc_bases_t = types; - typedef unique_usertype_traits uu_traits; - if constexpr (is_base_rebindable_v) { - using rebind_t = typename uu_traits::template rebind_base; - using cond_bases_t = meta::conditional_t::value, types<>, uc_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 - return 0; - } - string_view this_ti = usertype_traits::qualified_name(); - if (ti == this_ti) { - // direct match, return 1 - return 1; - } - return type_unique_cast_bases(cond_bases_t(), source_data, target_data, ti); - } - else { - (void)rebind_ti; - string_view this_ti = usertype_traits::qualified_name(); - if (ti == this_ti) { - // direct match, return 1 - return 1; - } - return type_unique_cast_bases(types<>(), 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 - -#endif // SOL_INHERITANCE_HPP -- cgit v1.2.3