update single, use special handling for find_package

This commit is contained in:
ThePhD 2018-01-23 16:18:17 -05:00
parent 63ec47bf6e
commit db9c5d64c6
4 changed files with 22 additions and 36 deletions

View File

@ -212,13 +212,14 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif() endif()
find_package(Threads) find_package(Threads)
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
# Find way to get Lua: build if requested, or attempt to build if no matching version is found # Find way to get Lua: build if requested, or attempt to build if no matching version is found
if (BUILD_LUA) if (BUILD_LUA)
find_package(LuaBuild ${LUA_VERSION} REQUIRED) find_package(LuaBuild REQUIRED COMPONENTS ${LUA_VERSION})
elseif (NOT LUA_VERSION) elseif (NOT LUA_VERSION)
find_package(LuaBuild REQUIRED) find_package(LuaBuild REQUIRED)
else() else()
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
if (NORMALIZED_LUA_VERSION MATCHES "5.1") if (NORMALIZED_LUA_VERSION MATCHES "5.1")
find_package(Lua 5.1 EXACT REQUIRED) find_package(Lua 5.1 EXACT REQUIRED)
elseif(NORMALIZED_LUA_VERSION MATCHES "5.2") elseif(NORMALIZED_LUA_VERSION MATCHES "5.2")
@ -233,7 +234,7 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
endif() endif()
if (NOT LUA_FOUND AND NOT LUABUILD_FOUND) if (NOT LUA_FOUND AND NOT LUABUILD_FOUND)
message(FATAL_ERROR "sol2 Lua \"${LUA_VERSION}\" not found and could not be targeted for building.") message(FATAL_ERROR "sol2 Lua \"${LUA_VERSION}\" not found and could not be targeted for building")
endif() endif()
# # Enable test harness for regular, example or single tests # # Enable test harness for regular, example or single tests

View File

@ -96,8 +96,8 @@ function(find_lua_build LUA_VERSION)
endfunction(find_lua_build) endfunction(find_lua_build)
# Call and then immediately undefine to avoid polluting the global scope # Call and then immediately undefine to avoid polluting the global scope
if (FIND_PACKAGE_VERSION) if (LuaBuild_FIND_COMPONENTS)
set(LUA_VERSION ${PACKAGE_FIND_VERSION}) list(GET LuaBuild_FIND_COMPONENTS 0 LUA_VERSION)
else() else()
set(LUA_VERSION 5.3.4) set(LUA_VERSION 5.3.4)
endif() endif()

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2018-01-23 16:58:47.295340 UTC // Generated 2018-01-23 21:17:54.182180 UTC
// This header was generated with sol v2.19.0 (revision 6ae78d9) // This header was generated with sol v2.19.0 (revision 63ec47b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -7496,8 +7496,6 @@ namespace sol {
// beginning of sol/inheritance.hpp // beginning of sol/inheritance.hpp
#include <atomic>
namespace sol { namespace sol {
template <typename... Args> template <typename... Args>
struct base_list {}; struct base_list {};
@ -7517,19 +7515,6 @@ namespace sol {
template <typename T> template <typename T>
bool has_derived<T>::value = false; bool has_derived<T>::value = false;
inline std::size_t unique_id() {
static std::atomic<std::size_t> x(0);
return ++x;
}
template <typename T>
struct id_for {
static const std::size_t value;
};
template <typename T>
const std::size_t id_for<T>::value = unique_id();
inline decltype(auto) base_class_check_key() { inline decltype(auto) base_class_check_key() {
static const auto& key = "class_check"; static const auto& key = "class_check";
return key; return key;
@ -7552,32 +7537,32 @@ namespace sol {
template <typename T, typename... Bases> template <typename T, typename... Bases>
struct inheritance { struct inheritance {
static bool type_check_bases(types<>, std::size_t) { static bool type_check_bases(types<>, const std::string& ti) {
return false; return false;
} }
template <typename Base, typename... Args> template <typename Base, typename... Args>
static bool type_check_bases(types<Base, Args...>, std::size_t ti) { static bool type_check_bases(types<Base, Args...>, const std::string& ti) {
return ti == id_for<Base>::value || type_check_bases(types<Args...>(), ti); return ti == usertype_traits<Base>::qualified_name() || type_check_bases(types<Args...>(), ti);
} }
static bool type_check(std::size_t ti) { static bool type_check(const std::string& ti) {
return ti == id_for<T>::value || type_check_bases(types<Bases...>(), ti); return ti == usertype_traits<T>::qualified_name() || type_check_bases(types<Bases...>(), ti);
} }
static void* type_cast_bases(types<>, T*, std::size_t) { static void* type_cast_bases(types<>, T*, const std::string&) {
return nullptr; return nullptr;
} }
template <typename Base, typename... Args> template <typename Base, typename... Args>
static void* type_cast_bases(types<Base, Args...>, T* data, std::size_t ti) { static void* type_cast_bases(types<Base, Args...>, T* data, const std::string& ti) {
// Make sure to convert to T first, and then dynamic cast to the proper type // Make sure to convert to T first, and then dynamic cast to the proper type
return ti != id_for<Base>::value ? type_cast_bases(types<Args...>(), data, ti) : static_cast<void*>(static_cast<Base*>(data)); return ti != usertype_traits<Base>::qualified_name() ? type_cast_bases(types<Args...>(), data, ti) : static_cast<void*>(static_cast<Base*>(data));
} }
static void* type_cast(void* voiddata, std::size_t ti) { static void* type_cast(void* voiddata, const std::string& ti) {
T* data = static_cast<T*>(voiddata); T* data = static_cast<T*>(voiddata);
return static_cast<void*>(ti != id_for<T>::value ? type_cast_bases(types<Bases...>(), data, ti) : data); return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(types<Bases...>(), data, ti) : data);
} }
}; };
@ -8014,7 +7999,7 @@ namespace stack {
if (type_of(L, -1) != type::lua_nil) { if (type_of(L, -1) != type::lua_nil) {
void* basecastdata = lua_touserdata(L, -1); void* basecastdata = lua_touserdata(L, -1);
detail::inheritance_check_function ic = reinterpret_cast<detail::inheritance_check_function>(basecastdata); detail::inheritance_check_function ic = reinterpret_cast<detail::inheritance_check_function>(basecastdata);
success = ic(detail::id_for<T>::value); success = ic(usertype_traits<T>::qualified_name());
} }
} }
if (!success) { if (!success) {
@ -8823,7 +8808,7 @@ namespace stack {
void* basecastdata = lua_touserdata(L, -1); void* basecastdata = lua_touserdata(L, -1);
detail::inheritance_cast_function ic = reinterpret_cast<detail::inheritance_cast_function>(basecastdata); detail::inheritance_cast_function ic = reinterpret_cast<detail::inheritance_cast_function>(basecastdata);
// use the casting function to properly adjust the pointer for the desired T // use the casting function to properly adjust the pointer for the desired T
udata = ic(udata, detail::id_for<T>::value); udata = ic(udata, usertype_traits<T>::qualified_name());
lua_pop(L, 1); lua_pop(L, 1);
} }
T* obj = static_cast<T*>(udata); T* obj = static_cast<T*>(udata);

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2018-01-23 16:58:47.490358 UTC // Generated 2018-01-23 21:17:54.350063 UTC
// This header was generated with sol v2.19.0 (revision 6ae78d9) // This header was generated with sol v2.19.0 (revision 63ec47b)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP