Preparing to separate the build from the table

This commit is contained in:
ThePhD 2021-09-15 03:24:47 -04:00
parent 6283d3c2be
commit b43cee5c9d
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
11 changed files with 541 additions and 123 deletions

View File

@ -29,8 +29,7 @@ set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Includes/Project.cm
# # # project declaration
project(sol2 VERSION 4.0.0 LANGUAGES CXX C)
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SOL2_IS_TOP_LEVEL TRUE)
if (sol2-is-top-level-project)
message(STATUS "sol2 is the top-level directory...")
endif()
@ -81,18 +80,24 @@ endif()
# # # sol2 Source Groups
# # Sources everyone is going to need
# Header files
file(GLOB SOL2_HEADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/include/sol*.hpp)
file(GLOB_RECURSE sol2-headers
LIST_DIRECTORIES FALSE
CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/include/sol*.hpp
)
file(GLOB_RECURSE sol2-sources
LIST_DIRECTORIES FALSE
CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/source/**
)
# # # sol2 Library
# # Add a target for sol2's library to be included by external users
add_library(sol2 INTERFACE)
add_library(sol2::sol2 ALIAS sol2)
target_sources(sol2 INTERFACE ${SOL2_SINGLE_HEADER_SOURCES})
set_target_properties(sol2
PROPERTIES
EXPORT_NAME sol2::sol2)
target_include_directories(sol2 ${sol2-system-include} INTERFACE
target_include_directories(sol2 ${sol2-system-include}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
@ -107,7 +112,8 @@ write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-config-version.cmake"
COMPATIBILITY AnyNewerVersion)
export(TARGETS sol2 FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-targets.cmake")
export(TARGETS sol2
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/sol2-targets.cmake")
if(SOL2_ENABLE_INSTALL)
install(TARGETS sol2
@ -126,8 +132,7 @@ if(SOL2_ENABLE_INSTALL)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/sol2")
endif()
# # # Single header target
# Find Python3 for single header / forward header generation
# # # sol2 Library - Single header target
if (SOL2_SINGLE)
message(STATUS "sol2 adding single...")
add_subdirectory(single)
@ -169,7 +174,7 @@ else()
endif()
# # # Tests, Examples and other CI suites that come with sol2
if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES))
if (sol2-is-top-level-project)
# # # General project output locations
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/lib")
@ -181,6 +186,14 @@ if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES))
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/bin")
endif()
if (NOT CMAKE_CXX_STANDARD GREATER_EQUAL 17)
set(CMAKE_CXX_STANDARD 17)
endif()
if (NOT CMAKE_C_STANDARD GREATER_EQUAL 11)
set(CMAKE_C_STANDARD 11)
endif()
# # # Libraries
# Here, we pull in all the necessary libraries for building examples and tests
# Find threading library
@ -255,7 +268,7 @@ if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES))
if (SOL2_DO_EXAMPLES)
# NOTE: will also add to tests if TESTS is defined
message(STATUS "sol2 adding examples...")
add_subdirectory(examples "${CMAKE_BINARY_DIR}/examples")
add_subdirectory(examples)
endif()
# # # Tests
@ -263,7 +276,7 @@ if (SOL2_IS_TOP_LEVEL AND (SOL2_DO_TESTS OR SOL2_DO_EXAMPLES))
if (SOL2_DO_TESTS)
# add subdir to get going
message(STATUS "sol2 adding tests...")
add_subdirectory(tests "${CMAKE_BINARY_DIR}/tests")
add_subdirectory(tests)
endif()
# # # Scratch Space

View File

@ -29,13 +29,10 @@ list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MESSAGE_CONTEXT "${PROJECT_NAME}")
# # Standard Project version
if (NOT CMAKE_CXX_STANDARD GREATER_EQUAL 17)
set(CMAKE_CXX_STANDARD 17)
endif()
if (NOT CMAKE_C_STANDARD GREATER_EQUAL 11)
set(CMAKE_C_STANDARD 11)
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(sol2-is-top-level-project TRUE)
else()
set(sol2-is-top-level-project FALSE)
endif()
# # CMake and sol2 Includes
@ -54,25 +51,27 @@ include(CheckCompilerDiagnostic)
include(CheckCompilerFlag)
include(FindVersion)
# # Check environment/prepare generator expressions
# Basic/Normal flags
check_compiler_flag(disable-permissive MSVC /permissive- GCC -pedantic)
check_compiler_flag(utf8-literal-encoding MSVC /execution-charset:utf-8 GCC -fexec-charset=utf-8)
check_compiler_flag(utf8-source-encoding MSVC /source-charset:utf-8 GCC -finput-charset=utf-8)
check_compiler_flag(extra-constexpr-depth MSVC /constexpr:depth2147483647 GCC -fconstexpr-depth=2147483647 CLANG -fconstexpr-depth=2147483647)
check_compiler_flag(extra-constexpr-steps MSVC /constexpr:steps2147483647 GCC -fconstexpr-ops-limit=2147483647 CLANG -fconstexpr-steps=2147483647)
check_compiler_flag(template-debugging-mode GCC -ftemplate-backtrace-limit=0)
check_compiler_flag(big-obj MSVC /bigobj)
# Overall warning flags
check_compiler_flag(pedantic GCC -pedantic)
check_compiler_flag(warn-pedantic GCC -Wpedantic)
check_compiler_flag(warn-all MSVC /W4 GCC -Wall)
check_compiler_flag(warn-extra GCC -Wextra)
check_compiler_flag(warn-errors MSVC /WX GCC -Werror)
# Individual warnings/errors
check_compiler_diagnostic(unknown-warning)
check_compiler_diagnostic(unknown-warning-option)
check_compiler_diagnostic(microsoft-cast)
check_compiler_diagnostic(noexcept-type)
check_compiler_diagnostic(unreachable-code MSVC 4702)
check_compiler_diagnostic(padding-from-alignment MSVC 4324)
if (sol2-is-top-level-project)
# # Check environment/prepare generator expressions
# Basic/Normal flags
check_compiler_flag(disable-permissive MSVC /permissive- GCC -pedantic)
check_compiler_flag(utf8-literal-encoding MSVC /execution-charset:utf-8 GCC -fexec-charset=utf-8)
check_compiler_flag(utf8-source-encoding MSVC /source-charset:utf-8 GCC -finput-charset=utf-8)
check_compiler_flag(extra-constexpr-depth MSVC /constexpr:depth2147483647 GCC -fconstexpr-depth=2147483647 CLANG -fconstexpr-depth=2147483647)
check_compiler_flag(extra-constexpr-steps MSVC /constexpr:steps2147483647 GCC -fconstexpr-ops-limit=2147483647 CLANG -fconstexpr-steps=2147483647)
check_compiler_flag(template-debugging-mode GCC -ftemplate-backtrace-limit=0)
check_compiler_flag(big-obj MSVC /bigobj)
# Overall warning flags
check_compiler_flag(pedantic GCC -pedantic)
check_compiler_flag(warn-pedantic GCC -Wpedantic)
check_compiler_flag(warn-all MSVC /W4 GCC -Wall)
check_compiler_flag(warn-extra GCC -Wextra)
check_compiler_flag(warn-errors MSVC /WX GCC -Werror)
# Individual warnings/errors
check_compiler_diagnostic(unknown-warning)
check_compiler_diagnostic(unknown-warning-option)
check_compiler_diagnostic(microsoft-cast)
check_compiler_diagnostic(noexcept-type)
check_compiler_diagnostic(unreachable-code MSVC 4702)
check_compiler_diagnostic(padding-from-alignment MSVC 4324)
endif()

View File

@ -24,18 +24,9 @@
include("${CMAKE_CURRENT_LIST_DIR}/sol2-targets.cmake")
MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
if (TARGET sol2)
get_target_property(SOL2_INCLUDE_DIRS
sol2 INTERFACE_INCLUDE_DIRECTORIES)
set_and_check(SOL2_INCLUDE_DIRS "${SOL2_INCLUDE_DIRS}")
set(SOL2_LIBRARIES sol2)
endif()
if(TARGET sol2_single)
get_target_property(SOL2_SINGLE_INCLUDE_DIRS
sol2_single INTERFACE_INCLUDE_DIRECTORIES)
set_and_check(SOL2_INCLUDE_DIRS "${SOL2_SINGLE_INCLUDE_DIRS}")
set(SOL2_LIBRARIES_SINGLE sol2_single)
endif()

View File

@ -0,0 +1,158 @@
// sol2
// The MIT License (MIT)
// Copyright (c) 2013-2021 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.
#pragma once
#ifndef SOL_DETAIL_BUILD_VERSION_HPP
#define SOL_DETAIL_BUILD_VERSION_HPP
#include <sol/version.hpp>
// clang-format off
#if defined(SOL_BUILD)
#if (SOL_BUILD != 0)
#define SOL_BUILD_I_ SOL_ON
#else
#define SOL_BUILD_I_ SOL_OFF
#endif
#else
#define SOL_BUILD_I_ SOL_DEFAULT_OFF
#endif // Building or not
#if defined(SOL_DLL)
#if (SOL_DLL != 0)
#define SOL_DLL_I_ SOL_ON
#else
#define SOL_DLL_I_ SOL_OFF
#endif
#elif SOL_IS_ON() && (defined(DLL_) || defined(_DLL))
#define SOL_DLL_I_ SOL_DEFAULT_ON
#else
#define SOL_DLL_I_ SOL_DEFAULT_OFF
#endif // DLL definition
#if defined(SOL_HEADER_ONLY)
#if (SOL_HEADER_ONLY != 0)
#define SOL_HEADER_ONLY_I_ SOL_ON
#else
#define SOL_HEADER_ONLY_I_ SOL_OFF
#endif
#else
#define SOL_HEADER_ONLY_I_ SOL_DEFAULT_OFF
#endif // Header only library
#if defined(SOL_UNITY_BUILD)
#if (SOL_UNITY_BUILD != 0)
#define SOL_UNITY_BUILD_I_ SOL_ON
#else
#define SOL_UNITY_BUILD_I_ SOL_OFF
#endif
#else
#define SOL_UNITY_BUILD_I_ SOL_DEFAULT_OFF
#endif // Header only library
#if defined(SOL_C_FUNCTION_LINKAGE)
#define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE
#else
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
// C++
#define SOL_C_FUNCTION_LINKAGE_I_ extern "C"
#else
// normal
#define SOL_C_FUNCTION_LINKAGE_I_
#endif // C++ or not
#endif // Linkage specification for C functions
#if defined(SOL_API_LINKAGE)
#define SOL_API_LINKAGE_I_ SOL_API_LINKAGE
#else
#if SOL_IS_ON(SOL_DLL_I_)
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_) || SOL_IS_ON(SOL_PLATFORM_WINDOWS_I_) || SOL_IS_ON(SOL_PLATFORM_CYGWIN_I_)
// MSVC Compiler; or, Windows, or Cygwin platforms
#if SOL_IS_ON(SOL_BUILD_I_)
// Building the library
#if SOL_IS_ON(SOL_COMPILER_GCC_I_)
// Using GCC
#define SOL_API_LINKAGE_I_ __attribute__((dllexport))
#else
// Using Clang, MSVC, etc...
#define SOL_API_LINKAGE_I_ __declspec(dllexport)
#endif
#else
#if SOL_IS_ON(SOL_PLATFORM_GCC_I_)
#define SOL_API_LINKAGE_I_ __attribute__((dllimport))
#else
#define SOL_API_LINKAGE_I_ __declspec(dllimport)
#endif
#endif
#else
// extern if building normally on non-MSVC
#define SOL_API_LINKAGE_I_ extern
#endif
#elif SOL_IS_ON(SOL_UNITY_BUILD_I_)
// Built-in library, like how stb typical works
#if SOL_IS_ON(SOL_HEADER_ONLY_I_)
// Header only, so functions are defined "inline"
#define SOL_API_LINKAGE_I_ inline
#else
// Not header only, so seperately compiled files
#define SOL_API_LINKAGE_I_ extern
#endif
#else
// Normal static library
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
#define SOL_API_LINKAGE_I_
#else
#define SOL_API_LINKAGE_I_ extern
#endif
#endif // DLL or not
#endif // Build definitions
#if defined(SOL_PUBLIC_FUNC_DECL)
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_PUBLIC_FUNC_DECL
#else
#define SOL_PUBLIC_FUNC_DECL_I_ SOL_API_LINKAGE_I_
#endif
#if defined(SOL_INTERNAL_FUNC_DECL_)
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_INTERNAL_FUNC_DECL_
#else
#define SOL_INTERNAL_FUNC_DECL_I_ SOL_API_LINKAGE_I_
#endif
#if defined(SOL_PUBLIC_FUNC_DEF)
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_PUBLIC_FUNC_DEF
#else
#define SOL_PUBLIC_FUNC_DEF_I_ SOL_API_LINKAGE_I_
#endif
#if defined(SOL_INTERNAL_FUNC_DEF)
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_INTERNAL_FUNC_DEF
#else
#define SOL_INTERNAL_FUNC_DEF_I_ SOL_API_LINKAGE_I_
#endif
// clang-format on
#endif // SOL_DETAIL_BUILD_VERSION_HPP

39
include/sol/epilogue.hpp Normal file
View File

@ -0,0 +1,39 @@
// sol2
// The MIT License (MIT)
// Copyright (c) 2013-2021 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.
#pragma once
// clang-format off
#if !defined(SOL_PROLOGUE_I_)
#error "[sol2] Library Prologue is missing from this translation unit."
#else
#undef SOL_PROLOGUE_I_
#endif
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
#undef _FWD
#undef _MOVE
#endif
// clang-format on

View File

@ -24,25 +24,16 @@
#ifndef SOL_PAIRS_ITERATOR_HPP
#define SOL_PAIRS_ITERATOR_HPP
#include <sol/version.hpp>
#include <sol/reference.hpp>
#include <sol/stack_reference.hpp>
#include <sol/table_iterator.hpp>
#include <sol/protected_function.hpp>
namespace sol {
#include <sol/detail/pairs.hpp>
namespace detail {
inline int c_lua_next(lua_State* L_) noexcept {
stack_reference table_stack_ref(L_, raw_index(1));
stateless_stack_reference key_stack_ref(L_, raw_index(2));
int result = lua_next(table_stack_ref.lua_state(), table_stack_ref.stack_index());
if (result == 0) {
stack::push(L_, lua_nil);
return 1;
}
return 2;
}
} // namespace detail
namespace sol {
struct pairs_sentinel { };
@ -108,7 +99,7 @@ namespace sol {
// just has a metatable, but does it have __pairs ?
stack_reference metatable(m_L, raw_index(abs_source_index));
stack::get_field<is_global_table_v<Source>, true>(m_L, meta_function::pairs, metatable.stack_index());
optional<protected_function> maybe_pairs_function = stack::pop<optional<function>>(m_L);
optional<protected_function> maybe_pairs_function = stack::pop<optional<protected_function>>(m_L);
if (maybe_pairs_function.has_value()) {
protected_function& pairs_function = *maybe_pairs_function;
protected_function_result next_fn_and_table_and_first_key = pairs_function(source_);
@ -145,7 +136,7 @@ namespace sol {
// okay, so none of the above worked and now we need to create
// a shim / polyfill instead
stack::push(m_L, &detail::c_lua_next);
stack::push(m_L, &stack::stack_detail::c_lua_next);
m_next_function_ref = stack::pop<protected_function>(m_L);
m_table_ref = source_;
stack::push(m_L, lua_nil);

47
include/sol/prologue.hpp Normal file
View File

@ -0,0 +1,47 @@
// sol2
// The MIT License (MIT)
// Copyright (c) 2013-2021 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.
#pragma once
// clang-format off
#if defined(SOL_PROLOGUE_I_)
#error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue."
#endif
#define SOL_PROLOGUE_I_ 1
#if SOL_IS_ON(SOL_BUILD_CXX_MODE_I_)
#define _FWD(...) static_cast<decltype( __VA_ARGS__ )&&>( __VA_ARGS__ )
#if SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
#define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ )
#else
#include <type_traits>
#define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) )
#endif
#endif
// clang-format on

View File

@ -50,7 +50,7 @@ namespace sol {
lua_State* L;
int& pop_count;
ref_clean(lua_State* L_, int& pop_count_) : L(L_), pop_count(pop_count_) {
ref_clean(lua_State* L_, int& pop_count_) noexcept : L(L_), pop_count(pop_count_) {
}
~ref_clean() {
lua_pop(L, static_cast<int>(pop_count));
@ -543,7 +543,8 @@ namespace sol {
table new_enum(const string_view& name, Args&&... args) {
table target = create_with(std::forward<Args>(args)...);
if (read_only) {
table x = create_with(meta_function::new_index, detail::fail_on_newindex, meta_function::index, target);
table x = create_with(
meta_function::new_index, detail::fail_on_newindex, meta_function::index, target, meta_function::pairs, detail::enum_pairs_function);
table shim = create_named(name, metatable_key, x);
return shim;
}

View File

@ -891,6 +891,15 @@ namespace sol {
struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>,
meta::supports_op_left_shift<std::ostream, meta::unqualified_t<T>>> { };
template <typename T>
inline constexpr bool is_to_stringable_v = is_to_stringable<T>::value;
template <typename T>
struct is_callable : std::true_type { };
template <typename T>
inline constexpr bool is_callable_v = is_callable_v<T>::value;
namespace detail {
template <typename T, typename = void>
struct lua_type_of : std::integral_constant<type, type::userdata> { };

View File

@ -159,15 +159,19 @@ namespace sol {
}
}
if (fx(meta_function::to_string)) {
if constexpr (is_to_stringable<T>::value && !meta::is_probably_stateless_lambda_v<T> && !std::is_member_pointer_v<T>) {
auto f = &detail::static_trampoline<&default_to_string<T>>;
ifx(meta_function::to_string, f);
if constexpr (is_to_stringable_v<T>) {
if constexpr (!meta::is_probably_stateless_lambda_v<T> && !std::is_member_pointer_v<T>) {
auto f = &detail::static_trampoline<&default_to_string<T>>;
ifx(meta_function::to_string, f);
}
}
}
if (fx(meta_function::call_function)) {
if constexpr (meta::call_operator_deducible_v<T>) {
auto f = &c_call<decltype(&T::operator()), &T::operator()>;
ifx(meta_function::call_function, f);
if constexpr (is_callable_v<T>) {
if constexpr (meta::call_operator_deducible_v<T>) {
auto f = &c_call<decltype(&T::operator()), &T::operator()>;
ifx(meta_function::call_function, f);
}
}
}
}

View File

@ -26,8 +26,6 @@
#include <sol/config.hpp>
#include <cstdint>
// clang-format off
#define SOL_VERSION_MAJOR 3
@ -46,45 +44,96 @@
#define SOL_DEFAULT_ON +
#define SOL_DEFAULT_OFF -
#if defined(_MSC_VER)
#if defined(__clang__)
#define SOL_COMPILER_CLANG_I_ SOL_OFF
#define SOL_COMPILER_GCC_I_ SOL_OFF
#define SOL_COMPILER_EDG_I_ SOL_OFF
#define SOL_COMPILER_VCXX_I_ SOL_ON
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_ON
#if defined(SOL_BUILD_CXX_MODE)
#if (SOL_BUILD_CXX_MODE != 0)
#define SOL_BUILD_CXX_MODE_I_ SOL_ON
#else
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_OFF
#define SOL_COMPILER_CLANG_I_ SOL_OFF
#define SOL_COMPILER_GCC_I_ SOL_OFF
#define SOL_COMPILER_EDG_I_ SOL_OFF
#define SOL_COMPILER_VCXX_I_ SOL_ON
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_OFF
#define SOL_BUILD_CXX_MODE_I_ SOL_OFF
#endif
#elif defined(__clang__)
#define SOL_COMPILER_CLANG_I_ SOL_ON
#define SOL_COMPILER_GCC_I_ SOL_OFF
#define SOL_COMPILER_EDG_I_ SOL_OFF
#define SOL_COMPILER_VCXX_I_ SOL_OFF
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_OFF
#elif defined(__GNUC__)
#define SOL_COMPILER_CLANG_I_ SOL_OFF
#define SOL_COMPILER_GCC_I_ SOL_ON
#define SOL_COMPILER_EDG_I_ SOL_OFF
#define SOL_COMPILER_VCXX_I_ SOL_OFF
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_OFF
#elif defined(__cplusplus)
#define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_CLANG_I_ SOL_OFF
#define SOL_COMPILER_GCC_I_ SOL_OFF
#define SOL_COMPILER_EDG_I_ SOL_OFF
#define SOL_COMPILER_VCXX_I_ SOL_OFF
#define SOL_COMPILER_VCXX_CLANG_I_ SOL_OFF
#define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_OFF
#endif
#if defined(__MINGW32__)
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_ON
#if defined(SOL_BUILD_C_MODE)
#if (SOL_BUILD_C_MODE != 0)
#define SOL_BUILD_C_MODE_I_ SOL_ON
#else
#define SOL_BUILD_C_MODE_I_ SOL_OFF
#endif
#elif defined(__STDC__)
#define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_FRONTEND_MINGW_I_ SOL_OFF
#define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_OFF
#endif
#if SOL_IS_ON(SOL_BUILD_C_MODE_I_)
#include <stddef.h>
#include <stdint.h>
#include <limits.h>
#else
#include <cstddef>
#include <cstdint>
#include <climits>
#endif
#if defined(SOL_COMPILER_VCXX)
#if defined(SOL_COMPILER_VCXX != 0)
#define SOL_COMPILER_VCXX_I_ SOL_ON
#else
#define SOL_COMPILER_VCXX_I_ SOL_OFF
#endif
#elif defined(_MSC_VER)
#define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_COMPILER_GCC)
#if defined(SOL_COMPILER_GCC != 0)
#define SOL_COMPILER_GCC_I_ SOL_ON
#else
#define SOL_COMPILER_GCC_I_ SOL_OFF
#endif
#elif defined(__GNUC__)
#define SOL_COMPILER_GCC_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_GCC_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_COMPILER_CLANG)
#if defined(SOL_COMPILER_CLANG != 0)
#define SOL_COMPILER_CLANG_I_ SOL_ON
#else
#define SOL_COMPILER_CLANG_I_ SOL_OFF
#endif
#elif defined(__clang__)
#define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_COMPILER_EDG)
#if defined(SOL_COMPILER_EDG != 0)
#define SOL_COMPILER_EDG_I_ SOL_ON
#else
#define SOL_COMPILER_EDG_I_ SOL_OFF
#endif
#else
#define SOL_COMPILER_EDG_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_COMPILER_MINGW)
#if (SOL_COMPILER_MINGW != 0)
#define SOL_COMPILER_MINGW_I_ SOL_ON
#else
#define SOL_COMPILER_MINGW_I_ SOL_OFF
#endif
#elif defined(__MINGW32__)
#define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_ON
#else
#define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_OFF
#endif
#if SIZE_MAX <= 0xFFFFULL
@ -458,12 +507,12 @@
#if SOL_IS_ON(SOL_COMPILER_CLANG_I_) && SOL_IS_ON(SOL_PLATFORM_APPLE_I_)
#if defined(__has_include)
#if __has_include(<variant>)
#define SOL_STD_VARIANT_I_ SOL_ON
#define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON
#else
#define SOL_STD_VARIANT_I_ SOL_OFF
#define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF
#endif
#else
#define SOL_STD_VARIANT_I_ SOL_OFF
#define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF
#endif
#else
#define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON
@ -550,7 +599,7 @@
#define SOL_USE_CXX_LUA_I_ SOL_OFF
#endif
#else
#define SOL_USE_CXX_LUA_I_ SOL_OFF
#define SOL_USE_CXX_LUA_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_USING_CXX_LUAJIT)
@ -566,7 +615,7 @@
#define SOL_USE_CXX_LUAJIT_I_ SOL_OFF
#endif
#else
#define SOL_USE_CXX_LUAJIT_I_ SOL_OFF
#define SOL_USE_CXX_LUAJIT_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_NO_LUA_HPP)
@ -614,7 +663,7 @@
#define SOL_USE_BOOST_I_ SOL_OFF
#endif
#else
#define SOL_USE_BOOST_I_ SOL_OFF
#define SOL_USE_BOOST_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_USE_UNSAFE_BASE_LOOKUP)
@ -624,7 +673,7 @@
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
#endif
#else
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
#define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_INSIDE_UNREAL)
@ -635,7 +684,7 @@
#endif
#else
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_ON
#else
#define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF
#endif
@ -671,9 +720,15 @@
#define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_DEFAULT_OFF
#endif
#if SOL_IS_ON(SOL_COMPILER_FRONTEND_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6)
#if defined(SOL_MINGW_CCTYPE_IS_POISONED)
#if (SOL_MINGW_CCTYPE_IS_POISONED != 0)
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON
#else
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_OFF
#endif
#elif SOL_IS_ON(SOL_COMPILER_MINGW_I_) && defined(__GNUC__) && (__GNUC__ < 6)
// MinGW is off its rocker in some places...
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_ON
#else
#define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF
#endif
@ -685,7 +740,7 @@
#define SOL_CHAR8_T_I_ SOL_OFF
#endif
#else
#ifdef __cpp_char8_t
#if defined(__cpp_char8_t)
#define SOL_CHAR8_T_I_ SOL_DEFAULT_ON
#else
#define SOL_CHAR8_T_I_ SOL_DEFAULT_OFF
@ -712,7 +767,7 @@
#define SOL2_CI_I_ SOL_OFF
#endif
#else
#define SOL2_CI_I_ SOL_OFF
#define SOL2_CI_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_C_ASSERT)
@ -727,6 +782,117 @@
#define SOL_USER_M_ASSERT_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_HEADER_ONLY)
#if (SOL_HEADER_ONLY != 0)
#define SOL_HEADER_ONLY_I_ SOL_ON
#else
#define SOL_HEADER_ONLY_I_ SOL_OFF
#endif
#else
#define SOL_HEADER_ONLY_I_ SOL_DEFAULT_ON
#endif
#if defined(SOL_BUILD)
#if (SOL_BUILD != 0)
#define SOL_BUILD_I_ SOL_ON
#else
#define SOL_BUILD_I_ SOL_OFF
#endif
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_BUILD_I_ SOL_DEFAULT_OFF
#else
#define SOL_BUILD_I_ SOL_DEFAULT_ON
#endif
#if defined(SOL_DLL)
#if (SOL_DLL != 0)
#define SOL_DLL_I_ SOL_ON
#else
#define SOL_DLL_I_ SOL_OFF
#endif
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_DLL_I_ SOL_DEFAULT_OFF
#else
#define SOL_DLL_I_ SOL_DEFAULT_OFF
#endif
#if defined(SOL_FUNC_DECL)
#define SOL_FUNC_DECL_I_ SOL_FUNC_DECL
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_FUNC_DECL_I_
#elif SOL_IS_ON(SOL_DLL_I_)
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
#if SOL_IS_ON(SOL_BUILD_I_)
#define SOL_FUNC_DECL_I_ extern __declspec(dllexport)
#else
#define SOL_FUNC_DECL_I_ extern __declspec(dllimport)
#endif
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
#define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default")))
#else
#define SOL_FUNC_DECL_I_ extern
#endif
#endif
#if defined(SOL_FUNC_DEFN)
#define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_FUNC_DEFN_I_ inline
#elif SOL_IS_ON(SOL_DLL_I_)
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
#if SOL_IS_ON(SOL_BUILD_I_)
#define SOL_FUNC_DEFN_I_ __declspec(dllexport)
#else
#define SOL_FUNC_DEFN_I_ __declspec(dllimport)
#endif
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
#define SOL_FUNC_DEFN_I_ __attribute__((visibility("default")))
#else
#define SOL_FUNC_DEFN_I_
#endif
#endif
#if defined(SOL_HIDDEN_FUNC_DECL)
#define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_HIDDEN_FUNC_DECL_I_
#elif SOL_IS_ON(SOL_DLL_I_)
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
#if SOL_IS_ON(SOL_BUILD_I_)
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport)
#else
#define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport)
#endif
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
#define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default")))
#else
#define SOL_HIDDEN_FUNC_DECL_I_ extern
#endif
#endif
#if defined(SOL_HIDDEN_FUNC_DEFN)
#define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN
#elif SOL_IS_ON(SOL_HEADER_ONLY_I_)
#define SOL_HIDDEN_FUNC_DEFN_I_ inline
#elif SOL_IS_ON(SOL_DLL_I_)
#if SOL_IS_ON(SOL_COMPILER_VCXX_I_)
#if SOL_IS_ON(SOL_BUILD_I_)
#define SOL_HIDDEN_FUNC_DEFN_I_
#else
#define SOL_HIDDEN_FUNC_DEFN_I_
#endif
#elif SOL_IS_ON(SOL_COMPILER_GCC_I_) || SOL_IS_ON(SOL_COMPILER_CLANG_I_)
#define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden")))
#else
#define SOL_HIDDEN_FUNC_DEFN_I_
#endif
#endif
#include <sol/prologue.hpp>
#include <sol/epilogue.hpp>
// clang-format on
#include <sol/detail/build_version.hpp>
#endif // SOL_VERSION_HPP