mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
update single, use special handling for find_package
This commit is contained in:
parent
63ec47bf6e
commit
db9c5d64c6
|
@ -212,13 +212,14 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
|
|||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
endif()
|
||||
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
|
||||
if (BUILD_LUA)
|
||||
find_package(LuaBuild ${LUA_VERSION} REQUIRED)
|
||||
find_package(LuaBuild REQUIRED COMPONENTS ${LUA_VERSION})
|
||||
elseif (NOT LUA_VERSION)
|
||||
find_package(LuaBuild REQUIRED)
|
||||
else()
|
||||
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
||||
if (NORMALIZED_LUA_VERSION MATCHES "5.1")
|
||||
find_package(Lua 5.1 EXACT REQUIRED)
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
# # Enable test harness for regular, example or single tests
|
||||
|
|
|
@ -96,8 +96,8 @@ function(find_lua_build LUA_VERSION)
|
|||
endfunction(find_lua_build)
|
||||
|
||||
# Call and then immediately undefine to avoid polluting the global scope
|
||||
if (FIND_PACKAGE_VERSION)
|
||||
set(LUA_VERSION ${PACKAGE_FIND_VERSION})
|
||||
if (LuaBuild_FIND_COMPONENTS)
|
||||
list(GET LuaBuild_FIND_COMPONENTS 0 LUA_VERSION)
|
||||
else()
|
||||
set(LUA_VERSION 5.3.4)
|
||||
endif()
|
||||
|
|
|
@ -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-01-23 16:58:47.295340 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 6ae78d9)
|
||||
// Generated 2018-01-23 21:17:54.182180 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 63ec47b)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -7496,8 +7496,6 @@ namespace sol {
|
|||
|
||||
// beginning of sol/inheritance.hpp
|
||||
|
||||
#include <atomic>
|
||||
|
||||
namespace sol {
|
||||
template <typename... Args>
|
||||
struct base_list {};
|
||||
|
@ -7517,19 +7515,6 @@ namespace sol {
|
|||
template <typename T>
|
||||
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() {
|
||||
static const auto& key = "class_check";
|
||||
return key;
|
||||
|
@ -7552,32 +7537,32 @@ namespace sol {
|
|||
|
||||
template <typename T, typename... Bases>
|
||||
struct inheritance {
|
||||
static bool type_check_bases(types<>, std::size_t) {
|
||||
static bool type_check_bases(types<>, const std::string& ti) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Base, typename... Args>
|
||||
static bool type_check_bases(types<Base, Args...>, std::size_t ti) {
|
||||
return ti == id_for<Base>::value || type_check_bases(types<Args...>(), ti);
|
||||
static bool type_check_bases(types<Base, Args...>, const std::string& ti) {
|
||||
return ti == usertype_traits<Base>::qualified_name() || type_check_bases(types<Args...>(), ti);
|
||||
}
|
||||
|
||||
static bool type_check(std::size_t ti) {
|
||||
return ti == id_for<T>::value || type_check_bases(types<Bases...>(), ti);
|
||||
static bool type_check(const std::string& 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;
|
||||
}
|
||||
|
||||
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
|
||||
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);
|
||||
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) {
|
||||
void* basecastdata = lua_touserdata(L, -1);
|
||||
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) {
|
||||
|
@ -8823,7 +8808,7 @@ namespace stack {
|
|||
void* basecastdata = lua_touserdata(L, -1);
|
||||
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
|
||||
udata = ic(udata, detail::id_for<T>::value);
|
||||
udata = ic(udata, usertype_traits<T>::qualified_name());
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
T* obj = static_cast<T*>(udata);
|
||||
|
|
|
@ -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-01-23 16:58:47.490358 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 6ae78d9)
|
||||
// Generated 2018-01-23 21:17:54.350063 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 63ec47b)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||
|
|
Loading…
Reference in New Issue
Block a user