mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Make base class type checks and lookup stable across DLLs
This commit is contained in:
parent
6ae78d9ed8
commit
63ec47bf6e
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -112,3 +112,4 @@ desktop.ini
|
|||
|
||||
# Miscellaneous
|
||||
external/
|
||||
scratch/
|
||||
|
|
|
@ -21,7 +21,10 @@
|
|||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# # # # sol2
|
||||
# # # Required minimum version statement
|
||||
cmake_minimum_required(VERSION 3.5.0)
|
||||
|
||||
# # # project declaration
|
||||
project(sol2 VERSION 2.19.0 LANGUAGES CXX C)
|
||||
|
||||
# # # General Project Requirements
|
||||
|
@ -63,8 +66,6 @@ else()
|
|||
list(APPEND CMAKE_C_FLAGS "-m32")
|
||||
list(APPEND CMAKE_CXX_FLAGS "-m32")
|
||||
list(APPEND CMAKE_EXE_LINKER_FLAGS "-m32")
|
||||
list(APPEND CMAKE_MODULE_LINKER_FLAGS "-m32")
|
||||
list(APPEND CMAKE_STATIC_LINKER_FLAGS "-m32")
|
||||
list(APPEND CMAKE_SHARED_LINKER_FLAGS "-m32")
|
||||
endif()
|
||||
add_compile_options(-Wno-unknown-warning -Wno-unknown-warning-option -Wall -Wextra -Wpedantic -pedantic -pedantic-errors)
|
||||
|
@ -105,7 +106,6 @@ include(CMakePackageConfigHelpers)
|
|||
# # Cached defines, strings, paths and options
|
||||
set(LUA_VERSION "5.3.4" CACHE STRING "The version of Lua needed. Can be 5.1, 5.2, 5.3, LuaJIT, or a more specific 3-part version number for a specifc Lua (e.g., 5.3.4 or luajit-2.0.5)")
|
||||
set(BUILD_LUA TRUE CACHE BOOL "Always build Lua, do not search for it in the system")
|
||||
set(BUILD_LUAJIT FALSE CACHE BOOL "Always build LuaJIT, do not search for it in the system")
|
||||
set(PLATFORM "x64" CACHE STRING "Target platform to compile for when building binaries (x86, x64)")
|
||||
option(CI "Enable build of tests" OFF)
|
||||
option(TESTS "Enable build of tests" OFF)
|
||||
|
@ -213,10 +213,10 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
|
|||
endif()
|
||||
find_package(Threads)
|
||||
# Find way to get Lua: build if requested, or attempt to build if no matching version is found
|
||||
if (BUILD_LUA OR BUILD_LUAJIT)
|
||||
include(LuaBuild)
|
||||
if (BUILD_LUA)
|
||||
find_package(LuaBuild ${LUA_VERSION} REQUIRED)
|
||||
elseif (NOT LUA_VERSION)
|
||||
# can't do anything
|
||||
find_package(LuaBuild REQUIRED)
|
||||
else()
|
||||
string(TOLOWER ${LUA_VERSION} NORMALIZED_LUA_VERSION)
|
||||
if (NORMALIZED_LUA_VERSION MATCHES "5.1")
|
||||
|
@ -228,11 +228,11 @@ if (TESTS OR TESTS_SINGLE OR TESTS_EXAMPLES OR EXAMPLES OR EXAMPLES_SINGLE)
|
|||
elseif(NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||
find_package(LuaJIT REQUIRED)
|
||||
else()
|
||||
include(LuaBuild)
|
||||
find_package(LuaBuild ${LUA_VERSION} REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT LUA_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.")
|
||||
endif()
|
||||
|
||||
|
|
112
cmake/Modules/FindLuaBuild.cmake
Normal file
112
cmake/Modules/FindLuaBuild.cmake
Normal file
|
@ -0,0 +1,112 @@
|
|||
# # # # sol2
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2013-2017 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.
|
||||
|
||||
# # Standard CMake Libraries
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# Contain literally everything inside of this function to prevent spillage
|
||||
function(find_lua_build LUA_VERSION)
|
||||
# # # Variables
|
||||
# # Core Paths
|
||||
string(TOLOWER ${LUA_VERSION} LUA_BUILD_NORMALIZED_LUA_VERSION)
|
||||
if (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||
elseif (BUILD_LUAJIT)
|
||||
set(LUA_BUILD_LIBNAME luajit-${LUA_VERSION})
|
||||
elseif (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "lua")
|
||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||
elseif (BUILD_LUA)
|
||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||
else()
|
||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||
endif()
|
||||
set(LUA_BUILD_TOPLEVEL "${CMAKE_BINARY_DIR}/vendor/${LUA_BUILD_LIBNAME}")
|
||||
set(LUA_BUILD_INSTALL_DIR "${LUA_BUILD_TOPLEVEL}")
|
||||
# # Misc needed variables
|
||||
set(LUA_BUILD_LIBRARY_DESCRIPTION "The base name of the library to build either the static or the dynamic library")
|
||||
|
||||
# Object file suffixes
|
||||
if (MSVC)
|
||||
set(LUA_BUILD_BUILD_DLL_DEFAULT ON)
|
||||
set(LUA_BUILD_OBJECT_FILE_SUFFIX .obj)
|
||||
else()
|
||||
set(LUA_BUILD_BUILD_DLL_DEFAULT OFF)
|
||||
set(LUA_BUILD_OBJECT_FILE_SUFFIX .o)
|
||||
endif()
|
||||
|
||||
|
||||
# # # Options
|
||||
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")
|
||||
|
||||
STRING(TOLOWER ${LUA_BUILD_LIBNAME} LUA_BUILD_NORMALIZED_LIBNAME)
|
||||
if (NOT LUA_LIBRARY_NAME)
|
||||
if (LUA_BUILD_NORMALIZED_LIBNAME MATCHES "luajit")
|
||||
set(LUA_LIBRARY luajit)
|
||||
else()
|
||||
set(LUA_LIBRARY ${LUA_BUILD_LIBNAME})
|
||||
endif()
|
||||
else()
|
||||
set(LUA_LIBRARY_NAME ${LUA_LIBRARY_NAME}
|
||||
CACHE STRING
|
||||
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
||||
endif()
|
||||
# # Dependent Variables
|
||||
# If we're building a DLL, then set the library type to SHARED
|
||||
if (BUILD_LUA_AS_DLL)
|
||||
set(LUA_BUILD_LIBRARY_TYPE SHARED)
|
||||
else()
|
||||
set(LUA_BUILD_LIBRARY_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
|
||||
# # # Build Lua
|
||||
# # Select either LuaJIT or Vanilla Lua here, based on what we discover
|
||||
if (BUILD_LUAJIT OR LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindLuaBuild/LuaJIT.cmake)
|
||||
set(LUA_VERSION_STRING ${LUA_JIT_VERSION})
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindLuaBuild/LuaVanilla.cmake)
|
||||
set(LUA_VERSION_STRING ${LUA_VANILLA_VERSION})
|
||||
endif()
|
||||
|
||||
# # Export variables to the parent scope
|
||||
set(LUA_LIBRARIES ${LUA_LIBRARIES} PARENT_SCOPE)
|
||||
set(LUA_INTERPRETER ${LUA_INTERPRETER} PARENT_SCOPE)
|
||||
set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE)
|
||||
set(LUABUILD_FOUND TRUE PARENT_SCOPE)
|
||||
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})
|
||||
else()
|
||||
set(LUA_VERSION 5.3.4)
|
||||
endif()
|
||||
find_lua_build(${LUA_VERSION})
|
||||
unset(find_lua_build)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUABUILD_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaBuild
|
||||
FOUND_VAR LUABUILD_FOUND
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INTERPRETER
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
|
@ -20,15 +20,15 @@
|
|||
# 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.
|
||||
|
||||
# import necessary standard modules
|
||||
include(ExternalProject)
|
||||
|
||||
# protect from multiple inclusion
|
||||
if(lua_jit_build_included)
|
||||
return()
|
||||
return()
|
||||
endif(lua_jit_build_included)
|
||||
set(lua_jit_build_included true)
|
||||
|
||||
# import necessary standard modules
|
||||
include(ExternalProject)
|
||||
|
||||
# Latest iterations for specific sub-versions of LuaJIT
|
||||
set(LUA_JIT_2.0_LATEST_VERSION 2.0.5)
|
||||
set(LUA_JIT_${LUA_JIT_2.0_LATEST_VERSION}_COMMIT c88602f080dcafea6ba222a2f7cc1ea0e41ef3cc)
|
||||
|
@ -117,7 +117,9 @@ else()
|
|||
MESSAGE(FATAL "Cannot deduce LuaJIT version from ${LUA_VERSION}")
|
||||
endif()
|
||||
|
||||
MESSAGE(STATUS "Selecting LuaJIT ${LUA_JIT_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library...")
|
||||
FIND_PACKAGE_MESSAGE(LUABUILD
|
||||
"Selecting LuaJIT ${LUA_JIT_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library..."
|
||||
"[${LUA_JIT_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}]")
|
||||
|
||||
# Get hashes for the build
|
||||
# LuaJIT unfortunately does not give us SHA1 hashes as well
|
||||
|
@ -156,6 +158,7 @@ set(LUA_JIT_LIB_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_FILENAME}"
|
|||
set(LUA_JIT_IMP_LIB_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_IMP_LIB_FILENAME}")
|
||||
set(LUA_JIT_LIB_EXP_FILE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}")
|
||||
set(LUA_JIT_DLL_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${LUA_JIT_DLL_FILENAME}")
|
||||
set(LUA_JIT_EXE_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${LUA_JIT_EXE_FILENAME}")
|
||||
|
||||
# # # Do the build
|
||||
if (MSVC)
|
||||
|
@ -205,6 +208,7 @@ else ()
|
|||
endif()
|
||||
|
||||
set(lualib luajitlib_${LUA_JIT_VERSION})
|
||||
set(luainterpreter luajit_${LUA_JIT_VERSION})
|
||||
|
||||
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_LIB}" LUA_JIT_SOURCE_LUA_LIB)
|
||||
file(TO_NATIVE_PATH "${LUA_JIT_LIB_FILE}" LUA_JIT_DESTINATION_LUA_LIB)
|
||||
|
@ -214,6 +218,8 @@ file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_DLL}" LUA_JIT_SOUR
|
|||
file(TO_NATIVE_PATH "${LUA_JIT_DLL_FILE}" LUA_JIT_DESTINATION_LUA_DLL)
|
||||
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/${LUA_JIT_PREBUILT_EXP}" LUA_JIT_SOURCE_LUA_LIB_EXP)
|
||||
file(TO_NATIVE_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${LUA_JIT_LIB_EXP_FILENAME}" LUA_JIT_DESTINATION_LUA_LIB_EXP)
|
||||
file(TO_NATIVE_PATH "${LUA_JIT_SOURCE_DIR}/luajit${CMAKE_EXECUTABLE_SUFFIX}" LUA_JIT_SOURCE_LUA_INTERPRETER)
|
||||
file(TO_NATIVE_PATH "${LUA_JIT_EXE_FILE}" LUA_JIT_DESTINATION_LUA_INTERPRETER)
|
||||
|
||||
if (WIN32 AND NOT MSVC)
|
||||
string(COMPARE EQUAL ${LUA_JIT_VERSION} ${LUA_JIT_2.0_LATEST_VERSION} lua_jit_same_version_20)
|
||||
|
@ -311,10 +317,16 @@ else()
|
|||
COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_LIB}\" to \"${LUA_JIT_DESTINATION_LUA_LIB}\"..."
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_LIB}" "${LUA_JIT_DESTINATION_LUA_LIB}" && echo Successfully moved!)
|
||||
endif()
|
||||
# # TODO:
|
||||
ExternalProject_Add_Step(LUA_JIT
|
||||
postbuild.exe
|
||||
DEPENDEES build
|
||||
COMMENT "Library - Moving \"${LUA_JIT_SOURCE_LUA_INTERPRETER}\" to \"${LUA_JIT_DESTINATION_LUA_INTERPRETER}\"..."
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "${LUA_JIT_SOURCE_LUA_INTERPRETER}" "${LUA_JIT_DESTINATION_LUA_INTERPRETER}" && echo Successfully moved!)
|
||||
# # TODO:
|
||||
# Add additional post-build step to move all necessary headers/lua files
|
||||
# for now, we just point directly to the `src` directory...
|
||||
|
||||
# # Lua Library
|
||||
add_library(${lualib} ${LUA_BUILD_LIBRARY_TYPE} IMPORTED)
|
||||
# make sure the library we export really does depend on Lua JIT's external project
|
||||
add_dependencies(${lualib} LUA_JIT)
|
||||
|
@ -344,7 +356,13 @@ if (XCODE)
|
|||
PUBLIC -pagezero_size 10000 -image_base 100000000)
|
||||
endif ()
|
||||
|
||||
# # Lua Executable
|
||||
add_executable(${luainterpreter} IMPORTED)
|
||||
# Point EXE to fiel
|
||||
set_target_properties(${luainterpreter}
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${LUA_JIT_EXE_FILE}")
|
||||
|
||||
# set externally-visible target indicator
|
||||
set(LUA_LIBRARIES ${lualib})
|
||||
set(LUAJIT_FOUND TRUE)
|
||||
set(LUA_FOUND TRUE)
|
||||
set(LUA_INTERPRETER ${luainterpreter})
|
|
@ -20,16 +20,15 @@
|
|||
# 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.
|
||||
|
||||
# Include guard
|
||||
if(_lua_vanilla_build_included)
|
||||
return()
|
||||
endif(_lua_vanilla_build_included)
|
||||
set(_lua_vanilla_build_included true)
|
||||
|
||||
# import necessary standard modules
|
||||
include(ExternalProject)
|
||||
|
||||
if(lua_build_included)
|
||||
return()
|
||||
endif(lua_build_included)
|
||||
set(lua_build_included true)
|
||||
|
||||
|
||||
|
||||
# Latest versions for specific sub-versions of Lua
|
||||
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
|
||||
set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4)
|
||||
|
@ -141,7 +140,9 @@ else()
|
|||
message(FATAL_ERROR "Cannot deduce the proper Lua version from ${LUA_VERSION}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library...")
|
||||
FIND_PACKAGE_MESSAGE(LUABUILD
|
||||
"Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library..."
|
||||
"[${LUA_VANILLA_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}]")
|
||||
|
||||
# Get Hashes to use for download
|
||||
set(LUA_VANILLA_SHA1 ${LUA_VANILLA_SHA1_${LUA_VANILLA_VERSION}})
|
||||
|
@ -238,7 +239,6 @@ ExternalProject_Add(LUA_VANILLA
|
|||
|
||||
# make a quick lua.hpp for 5.1 targets that don't have it
|
||||
if (LUA_VANILLA_GENERATE_LUA_HPP)
|
||||
message(STATUS "Will generate lua.hpp for this version of Lua...")
|
||||
set(LUA_VANILLA_LUA_HPP_CONTENT "// lua.hpp
|
||||
// Lua header files for C++
|
||||
// <<extern \"C\">> not supplied automatically because Lua also compiles as C++
|
||||
|
@ -399,4 +399,5 @@ endif()
|
|||
|
||||
# set externally-visible target indicator
|
||||
set(LUA_LIBRARIES ${liblua})
|
||||
set(LUA_FOUND TRUE)
|
||||
set(LUA_INTERPRETER ${luainterpreter})
|
||||
set(LUA_COMPILER ${luacompiler})
|
|
@ -1,91 +0,0 @@
|
|||
# # # # sol2
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2013-2017 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.
|
||||
|
||||
# # # Variables
|
||||
# # Core Paths
|
||||
string(TOLOWER ${LUA_VERSION} LUA_BUILD_NORMALIZED_LUA_VERSION)
|
||||
if (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||
elseif (BUILD_LUAJIT)
|
||||
set(LUA_BUILD_LIBNAME luajit-${LUA_VERSION})
|
||||
elseif (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "lua")
|
||||
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
||||
elseif (BUILD_LUA)
|
||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||
else()
|
||||
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
||||
endif()
|
||||
set(LUA_BUILD_TOPLEVEL "${CMAKE_BINARY_DIR}/vendor/${LUA_BUILD_LIBNAME}")
|
||||
set(LUA_BUILD_INSTALL_DIR "${LUA_BUILD_TOPLEVEL}")
|
||||
# # Misc needed variables
|
||||
set(LUA_BUILD_LIBRARY_DESCRIPTION "The base name of the library to build either the static or the dynamic library")
|
||||
|
||||
# Object file suffixes
|
||||
if (MSVC)
|
||||
set(LUA_BUILD_BUILD_DLL_DEFAULT ON)
|
||||
set(LUA_BUILD_OBJECT_FILE_SUFFIX .obj)
|
||||
else()
|
||||
set(LUA_BUILD_BUILD_DLL_DEFAULT OFF)
|
||||
set(LUA_BUILD_OBJECT_FILE_SUFFIX .o)
|
||||
endif()
|
||||
|
||||
|
||||
# # # Options
|
||||
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")
|
||||
|
||||
STRING(TOLOWER ${LUA_BUILD_LIBNAME} LUA_BUILD_NORMALIZED_LIBNAME)
|
||||
if (NOT LUA_LIBRARY_NAME)
|
||||
if (LUA_BUILD_NORMALIZED_LIBNAME MATCHES "luajit")
|
||||
set(LUA_LIBRARY luajit)
|
||||
else()
|
||||
set(LUA_LIBRARY ${LUA_BUILD_LIBNAME})
|
||||
endif()
|
||||
else()
|
||||
set(LUA_LIBRARY_NAME ${LUA_LIBRARY_NAME}
|
||||
CACHE STRING
|
||||
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
||||
endif()
|
||||
# # Dependent Variables
|
||||
# If we're building a DLL, then set the library type to SHARED
|
||||
if (BUILD_LUA_AS_DLL)
|
||||
set(LUA_BUILD_LIBRARY_TYPE SHARED)
|
||||
else()
|
||||
set(LUA_BUILD_LIBRARY_TYPE STATIC)
|
||||
endif()
|
||||
|
||||
|
||||
# # # Build Lua
|
||||
# # Select either LuaJIT or Vanilla Lua here, based on what we discover
|
||||
if (BUILD_LUAJIT OR LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
||||
include(LuaJITBuild)
|
||||
else()
|
||||
include(LuaVanillaBuild)
|
||||
endif()
|
||||
|
||||
# # # Variable cleanup
|
||||
unset(LUA_BUILD_LIBNAME)
|
||||
unset(LUA_BUILD_NORMALIZED_LUA_VERSION)
|
||||
unset(LUA_BUILD_LIBRARY_DESCRIPTION)
|
||||
unset(LUA_BUILD_DYNAMIC_LIBRARY_DESCRIPTION)
|
||||
unset(LUA_BUILD_BUILD_DLL_DEFAULT)
|
||||
unset(LUA_BUILD_OBJECT_FILE_SUFFIX)
|
||||
unset(LUA_BUILD_LIBRARY_TYPE)
|
|
@ -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-20 19:31:24.245892 UTC
|
||||
// This header was generated with sol v2.19.0 (revision cbd7923)
|
||||
// Generated 2018-01-23 16:58:47.295340 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 6ae78d9)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -8626,7 +8626,7 @@ namespace stack {
|
|||
thread_local std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
|
||||
std::wstring r = convert.from_bytes(str, str + len);
|
||||
#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 7
|
||||
// Fuck you, MinGW, and fuck you libstdc++ for introducing this absolutely asinine bug
|
||||
// Thanks, MinGW and libstdc++, for introducing this absolutely asinine bug
|
||||
// https://sourceforge.net/p/mingw-w64/bugs/538/
|
||||
// http://chat.stackoverflow.com/transcript/message/32271369#32271369
|
||||
for (auto& c : r) {
|
||||
|
@ -16652,6 +16652,7 @@ namespace sol {
|
|||
// end of sol/usertype_core.hpp
|
||||
|
||||
#include <cstdio>
|
||||
#include <bitset>
|
||||
|
||||
namespace sol {
|
||||
namespace usertype_detail {
|
||||
|
@ -17011,7 +17012,7 @@ namespace sol {
|
|||
void* baseclasscheck;
|
||||
void* baseclasscast;
|
||||
bool secondarymeta;
|
||||
std::array<bool, 32> properties;
|
||||
std::bitset<32> properties;
|
||||
|
||||
template <std::size_t Idx, meta::enable<std::is_same<lua_CFunction, meta::unqualified_tuple_element<Idx + 1, RawTuple>>> = meta::enabler>
|
||||
lua_CFunction make_func() const {
|
||||
|
@ -17076,12 +17077,11 @@ namespace sol {
|
|||
luaL_Reg reg = usertype_detail::make_reg(std::forward<N>(n), make_func<Idx>());
|
||||
for (std::size_t i = 0; i < properties.size(); ++i) {
|
||||
meta_function mf = static_cast<meta_function>(i);
|
||||
bool& prop = properties[i];
|
||||
const std::string& mfname = to_string(mf);
|
||||
if (mfname == reg.name) {
|
||||
switch (mf) {
|
||||
case meta_function::construct:
|
||||
if (prop) {
|
||||
if (properties[i]) {
|
||||
#ifndef SOL_NO_EXCEPTIONS
|
||||
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
|
||||
#else
|
||||
|
@ -17102,17 +17102,17 @@ namespace sol {
|
|||
case meta_function::index:
|
||||
indexfunc = reg.func;
|
||||
mustindex = true;
|
||||
prop = true;
|
||||
properties.set(i);
|
||||
return;
|
||||
case meta_function::new_index:
|
||||
newindexfunc = reg.func;
|
||||
mustindex = true;
|
||||
prop = true;
|
||||
properties.set(i);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
prop = true;
|
||||
properties.set(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -17123,7 +17123,7 @@ namespace sol {
|
|||
template <typename... Args, typename = std::enable_if_t<sizeof...(Args) == sizeof...(Tn)>>
|
||||
usertype_metatable(Args&&... args)
|
||||
: usertype_metatable_core(&usertype_detail::indexing_fail<T, true>, &usertype_detail::metatable_newindex<T, false>), usertype_detail::registrar(), functions(std::forward<Args>(args)...), destructfunc(nullptr), callconstructfunc(nullptr), indexbase(&core_indexing_call<true>), newindexbase(&core_indexing_call<false>), indexbaseclasspropogation(usertype_detail::walk_all_bases<true>), newindexbaseclasspropogation(usertype_detail::walk_all_bases<false>), baseclasscheck(nullptr), baseclasscast(nullptr), secondarymeta(contains_variable()), properties() {
|
||||
properties.fill(false);
|
||||
properties.reset();
|
||||
std::initializer_list<typename usertype_detail::mapping_t::value_type> ilist{{std::pair<std::string, usertype_detail::call_information>(usertype_detail::make_string(std::get<I * 2>(functions)),
|
||||
usertype_detail::call_information(&usertype_metatable::real_find_call<I * 2, I * 2 + 1, true>,
|
||||
&usertype_metatable::real_find_call<I * 2, I * 2 + 1, false>))}...};
|
||||
|
|
|
@ -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-20 19:31:24.431906 UTC
|
||||
// This header was generated with sol v2.19.0 (revision cbd7923)
|
||||
// Generated 2018-01-23 16:58:47.490358 UTC
|
||||
// This header was generated with sol v2.19.0 (revision 6ae78d9)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#define SOL_INHERITANCE_HPP
|
||||
|
||||
#include "types.hpp"
|
||||
#include <atomic>
|
||||
|
||||
namespace sol {
|
||||
template <typename... Args>
|
||||
|
@ -46,19 +45,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;
|
||||
|
@ -81,32 +67,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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -456,7 +456,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) {
|
||||
|
|
|
@ -467,7 +467,7 @@ namespace stack {
|
|||
thread_local std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
|
||||
std::wstring r = convert.from_bytes(str, str + len);
|
||||
#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 7
|
||||
// Fuck you, MinGW, and fuck you libstdc++ for introducing this absolutely asinine bug
|
||||
// Thanks, MinGW and libstdc++, for introducing this absolutely asinine bug
|
||||
// https://sourceforge.net/p/mingw-w64/bugs/538/
|
||||
// http://chat.stackoverflow.com/transcript/message/32271369#32271369
|
||||
for (auto& c : r) {
|
||||
|
@ -664,7 +664,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);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
|
||||
#include "test_stack_guard.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user