mmm double trampolining is not good

add new ways to shoot myself in the foot with CMake
This commit is contained in:
ThePhD 2019-12-23 09:09:23 -05:00
parent 1f27149239
commit 36972a994b
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
5 changed files with 94 additions and 75 deletions

View File

@ -144,9 +144,17 @@ else()
message(FATAL_ERROR "Cannot deduce the proper Lua version from ${LUA_VERSION}")
endif()
if (BUILD_LUA_AS_CXX)
set(LUA_VANILLA_LANGUAGE CXX)
set(LUA_VANILLA_LANGUAGE_STANDARD 98)
else()
set(LUA_VANILLA_LANGUAGE C)
set(LUA_VANILLA_LANGUAGE_STANDARD 99)
endif()
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}]")
"Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library with ${LUA_VANILLA_LANGUAGE} linkage..."
"[${LUA_VANILLA_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}][${LUA_VANILLA_LANGUAGE}]")
# Get Hashes to use for download
set(LUA_VANILLA_SHA1 ${LUA_VANILLA_SHA1_${LUA_VANILLA_VERSION}})
@ -322,15 +330,17 @@ set(luacompiler "luac-${LUA_VANILLA_VERSION}")
add_library(${liblua} ${LUA_BUILD_LIBRARY_TYPE} "${LUA_VANILLA_LIB_SOURCES}")
set_target_properties(${liblua}
PROPERTIES
LANGUAGE C
LINKER_LANGUAGE C
C_STANDARD 99
C_EXTENSIONS TRUE
LANGUAGE ${LUA_VANILLA_LANGUAGE}
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
${LUA_VANILLA_LANGUAGE}_STANDARD ${LUA_VANILLA_LANGUAGE_STANDARD}
${LUA_VANILLA_LANGUAGE}_EXTENSIONS TRUE
POSITION_INDEPENDENT_CODE TRUE
OUTPUT_NAME ${LUA_BUILD_LIBNAME}
RUNTIME_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
LIBRARY_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
ARCHIVE_OUTPUT_NAME ${LUA_BUILD_LIBNAME})
set_source_files_properties(${LUA_VANILLA_LIB_SOURCES}
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
target_include_directories(${liblua}
PUBLIC "${LUA_VANILLA_INCLUDE_DIRS}")
target_compile_definitions(${liblua}
@ -361,50 +371,55 @@ endif()
# we don't really need this section...
# Lua Interpreter
add_executable(${luainterpreter} ${LUA_VANILLA_LUA_SOURCES})
set_target_properties(${luainterpreter}
PROPERTIES
LANGUAGE C
LINKER_LANGUAGE C
C_STANDARD 99
C_EXTENSIONS TRUE
OUTPUT_NAME lua-${LUA_VANILLA_VERSION})
target_include_directories(${luainterpreter}
PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}")
target_compile_definitions(${luainterpreter}
PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}
PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE})
if (MSVC)
target_compile_options(${luainterpreter}
PRIVATE /W1)
else()
target_compile_options(${luainterpreter}
PRIVATE -w)
endif()
if (WIN32)
#target_compile_definitions(${luainterpreter}
# PRIVATE LUA_USE_WINDOWS)
else()
target_compile_definitions(${luainterpreter}
PRIVATE LUA_USE_LINUX)
endif()
target_link_libraries(${luainterpreter} PRIVATE ${liblua})
if (CMAKE_DL_LIBS)
target_link_libraries(${luainterpreter} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (UNIX)
target_link_libraries(${luainterpreter} PRIVATE m readline)
if (LUA_BUILD_LUA_INTERPRETER)
add_executable(${luainterpreter} ${LUA_VANILLA_LUA_SOURCES})
set_target_properties(${luainterpreter}
PROPERTIES
LANGUAGE ${LUA_VANILLA_LANGUAGE}
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
${LUA_VANILLA_LANGUAGE}_STANDARD ${LUA_VANILLA_LANGUAGE_STANDARD}
${LUA_VANILLA_LANGUAGE}_EXTENSIONS TRUE
OUTPUT_NAME lua-${LUA_VANILLA_VERSION})
set_source_files_properties(${LUA_VANILLA_LUA_SOURCES}
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
target_include_directories(${luainterpreter}
PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}")
target_compile_definitions(${luainterpreter}
PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}
PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE})
if (MSVC)
target_compile_options(${luainterpreter}
PRIVATE /W1)
else()
target_compile_options(${luainterpreter}
PRIVATE -w)
endif()
if (WIN32)
#target_compile_definitions(${luainterpreter}
# PRIVATE LUA_USE_WINDOWS)
else()
target_compile_definitions(${luainterpreter}
PRIVATE LUA_USE_LINUX)
endif()
target_link_libraries(${luainterpreter} PRIVATE ${liblua})
if (CMAKE_DL_LIBS)
target_link_libraries(${luainterpreter} PRIVATE ${CMAKE_DL_LIBS})
endif()
if (UNIX)
target_link_libraries(${luainterpreter} PRIVATE m readline)
endif()
endif()
# LuaC Compiler
if (LUA_BUILD_LUA_COMPILER)
add_executable(${luainterpreter} ${LUA_VANILLA_LUA_SOURCES})
set_target_properties(${luacompiler}
PROPERTIES
LANGUAGE C
LINKER_LANGUAGE C
C_STANDARD 99
C_EXTENSIONS TRUE
LANGUAGE ${LUA_VANILLA_LANGUAGE}
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
OUTPUT_NAME luac-${LUA_VANILLA_VERSION})
set_source_files_properties(${LUA_VANILLA_LIB_SOURCES}
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
target_include_directories(${luacompiler}
PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}")
target_compile_definitions(${luacompiler}

View File

@ -30,7 +30,7 @@
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#if defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT
#if (defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT) || (defined(LUAJIT_VERSION) && LUAJIT_VERSION)
#include <luajit.h>
#endif // C++ LuaJIT ... whatever that means
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !(SOL_EXCEPTIONS_SAFE_PROPAGATION)) && (!defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE) || !(SOL_EXCEPTIONS_ALWAYS_UNSAFE))

View File

@ -70,9 +70,11 @@ namespace sol {
template <bool is_yielding, typename Fx, typename... Args>
void select(lua_State* L, Fx&& fx, Args&&... args);
template <bool is_yielding, typename Fx, typename... Args>
template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
void select_set_fx(lua_State* L, Args&&... args) {
lua_CFunction freefunc = detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>;
lua_CFunction freefunc = no_trampoline ?
detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>
: function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>;
int upvalues = 0;
upvalues += stack::push(L, nullptr);
@ -90,8 +92,8 @@ namespace sol {
select<is_yielding>(L, std::move(fxptr), std::forward<Args>(args)...);
}
else {
using F = function_detail::functor_function<dFx, is_yielding, true>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
using F = function_detail::functor_function<dFx, false, true>;
select_set_fx<is_yielding, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
@ -140,14 +142,14 @@ namespace sol {
else {
using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
using F = function_detail::member_variable<Tu, clean_fx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
else {
using C = typename meta::bind_traits<uFx>::object_type;
using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
using F = function_detail::member_variable<C, clean_fx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
@ -179,7 +181,7 @@ namespace sol {
}
else {
using F = function_detail::member_function<Tu, dFx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
}
}
}
@ -384,13 +386,13 @@ namespace sol {
struct unqualified_pusher<overload_set<Functions...>> {
static int push(lua_State* L, overload_set<Functions...>&& set) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(set.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(set.functions));
return 1;
}
static int push(lua_State* L, const overload_set<Functions...>& set) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, set.functions);
function_detail::select_set_fx<false, false, F>(L, set.functions);
return 1;
}
};
@ -455,25 +457,25 @@ namespace sol {
struct unqualified_pusher<factory_wrapper<Functions...>> {
static int push(lua_State* L, const factory_wrapper<Functions...>& fw) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, fw.functions);
function_detail::select_set_fx<false, false, F>(L, fw.functions);
return 1;
}
static int push(lua_State* L, factory_wrapper<Functions...>&& fw) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(fw.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
return 1;
}
static int push(lua_State* L, const factory_wrapper<Functions...>& fw, function_detail::call_indicator) {
using F = function_detail::overloaded_function<1, Functions...>;
function_detail::select_set_fx<false, F>(L, fw.functions);
function_detail::select_set_fx<false, false, F>(L, fw.functions);
return 1;
}
static int push(lua_State* L, factory_wrapper<Functions...>&& fw, function_detail::call_indicator) {
using F = function_detail::overloaded_function<1, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(fw.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
return 1;
}
};

View File

@ -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 2019-12-02 20:54:28.461558 UTC
// This header was generated with sol v3.2.0 (revision 38d9792)
// Generated 2019-12-23 14:09:10.625316 UTC
// This header was generated with sol v3.2.0 (revision 1f27149)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -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 2019-12-02 20:54:28.195238 UTC
// This header was generated with sol v3.2.0 (revision 38d9792)
// Generated 2019-12-23 14:09:10.057090 UTC
// This header was generated with sol v3.2.0 (revision 1f27149)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -2118,7 +2118,7 @@ namespace sol {
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#if defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT
#if (defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT) || (defined(LUAJIT_VERSION) && LUAJIT_VERSION)
#include <luajit.h>
#endif // C++ LuaJIT ... whatever that means
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !(SOL_EXCEPTIONS_SAFE_PROPAGATION)) && (!defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE) || !(SOL_EXCEPTIONS_ALWAYS_UNSAFE))
@ -17743,9 +17743,11 @@ namespace sol {
template <bool is_yielding, typename Fx, typename... Args>
void select(lua_State* L, Fx&& fx, Args&&... args);
template <bool is_yielding, typename Fx, typename... Args>
template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
void select_set_fx(lua_State* L, Args&&... args) {
lua_CFunction freefunc = detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>;
lua_CFunction freefunc = no_trampoline ?
detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>
: function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>;
int upvalues = 0;
upvalues += stack::push(L, nullptr);
@ -17763,8 +17765,8 @@ namespace sol {
select<is_yielding>(L, std::move(fxptr), std::forward<Args>(args)...);
}
else {
using F = function_detail::functor_function<dFx, is_yielding, true>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
using F = function_detail::functor_function<dFx, false, true>;
select_set_fx<is_yielding, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
@ -17813,14 +17815,14 @@ namespace sol {
else {
using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
using F = function_detail::member_variable<Tu, clean_fx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
else {
using C = typename meta::bind_traits<uFx>::object_type;
using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
using F = function_detail::member_variable<C, clean_fx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
}
}
@ -17852,7 +17854,7 @@ namespace sol {
}
else {
using F = function_detail::member_function<Tu, dFx, is_yielding>;
select_set_fx<false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
select_set_fx<false, false, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
}
}
}
@ -18057,13 +18059,13 @@ namespace sol {
struct unqualified_pusher<overload_set<Functions...>> {
static int push(lua_State* L, overload_set<Functions...>&& set) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(set.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(set.functions));
return 1;
}
static int push(lua_State* L, const overload_set<Functions...>& set) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, set.functions);
function_detail::select_set_fx<false, false, F>(L, set.functions);
return 1;
}
};
@ -18128,25 +18130,25 @@ namespace sol {
struct unqualified_pusher<factory_wrapper<Functions...>> {
static int push(lua_State* L, const factory_wrapper<Functions...>& fw) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, fw.functions);
function_detail::select_set_fx<false, false, F>(L, fw.functions);
return 1;
}
static int push(lua_State* L, factory_wrapper<Functions...>&& fw) {
using F = function_detail::overloaded_function<0, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(fw.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
return 1;
}
static int push(lua_State* L, const factory_wrapper<Functions...>& fw, function_detail::call_indicator) {
using F = function_detail::overloaded_function<1, Functions...>;
function_detail::select_set_fx<false, F>(L, fw.functions);
function_detail::select_set_fx<false, false, F>(L, fw.functions);
return 1;
}
static int push(lua_State* L, factory_wrapper<Functions...>&& fw, function_detail::call_indicator) {
using F = function_detail::overloaded_function<1, Functions...>;
function_detail::select_set_fx<false, F>(L, std::move(fw.functions));
function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
return 1;
}
};