update single
This commit is contained in:
ThePhD 2018-06-15 15:50:51 -04:00
parent 2777b6ad15
commit 92f3330e03
4 changed files with 22440 additions and 21961 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,357 +1,361 @@
// The MIT License (MIT) // The MIT License (MIT)
// Copyright (c) 2013-2018 Rapptz, ThePhD and contributors // Copyright (c) 2013-2018 Rapptz, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of // 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 // this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to // the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // 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, // the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions: // subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all // The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software. // copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // 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 // 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 // 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. // 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-06-11 18:42:24.829810 UTC // Generated 2018-06-15 19:50:08.054132 UTC
// This header was generated with sol v2.20.2 (revision ac70911) // This header was generated with sol v2.20.2 (revision 2777b6a)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
#define SOL_SINGLE_INCLUDE_FORWARD_HPP #define SOL_SINGLE_INCLUDE_FORWARD_HPP
// beginning of sol/forward.hpp // beginning of sol/forward.hpp
// beginning of sol/feature_test.hpp // beginning of sol/feature_test.hpp
#if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)))) #if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))))
#ifndef SOL_CXX17_FEATURES #ifndef SOL_CXX17_FEATURES
#define SOL_CXX17_FEATURES 1 #define SOL_CXX17_FEATURES 1
#endif // C++17 features macro #endif // C++17 features macro
#endif // C++17 features check #endif // C++17 features check
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES #if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(__cpp_noexcept_function_type) || ((defined(_MSC_VER) && _MSC_VER > 1911) && (defined(_MSVC_LANG) && ((_MSVC_LANG >= 201403L)))) #if defined(__cpp_noexcept_function_type) || ((defined(_MSC_VER) && _MSC_VER > 1911) && (defined(_MSVC_LANG) && ((_MSVC_LANG >= 201403L))))
#ifndef SOL_NOEXCEPT_FUNCTION_TYPE #ifndef SOL_NOEXCEPT_FUNCTION_TYPE
#define SOL_NOEXCEPT_FUNCTION_TYPE 1 #define SOL_NOEXCEPT_FUNCTION_TYPE 1
#endif // noexcept is part of a function's type #endif // noexcept is part of a function's type
#endif // compiler-specific checks #endif // compiler-specific checks
#if defined(__clang__) && defined(__APPLE__) #if defined(__clang__) && defined(__APPLE__)
#if defined(__has_include) #if defined(__has_include)
#if __has_include(<variant>) #if __has_include(<variant>)
#define SOL_STD_VARIANT 1 #define SOL_STD_VARIANT 1
#endif // has include nonsense #endif // has include nonsense
#endif // __has_include #endif // __has_include
#else #else
#define SOL_STD_VARIANT 1 #define SOL_STD_VARIANT 1
#endif // Clang screws up variant #endif // Clang screws up variant
#endif // C++17 only #endif // C++17 only
// beginning of sol/config.hpp // beginning of sol/config.hpp
#ifdef _MSC_VER #ifdef _MSC_VER
#if defined(_DEBUG) && !defined(NDEBUG) #if defined(_DEBUG) && !defined(NDEBUG)
#ifndef SOL_IN_DEBUG_DETECTED #ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1 #define SOL_IN_DEBUG_DETECTED 1
#endif #endif
#endif // VC++ Debug macros #endif // VC++ Debug macros
#ifndef _CPPUNWIND #ifndef _CPPUNWIND
#ifndef SOL_NO_EXCEPTIONS #ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1 #define SOL_NO_EXCEPTIONS 1
#endif #endif
#endif // Automatic Exceptions #endif // Automatic Exceptions
#ifndef _CPPRTTI #ifndef _CPPRTTI
#ifndef SOL_NO_RTTI #ifndef SOL_NO_RTTI
#define SOL_NO_RTTI 1 #define SOL_NO_RTTI 1
#endif #endif
#endif // Automatic RTTI #endif // Automatic RTTI
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__)
#if !defined(NDEBUG) && !defined(__OPTIMIZE__) #if !defined(NDEBUG) && !defined(__OPTIMIZE__)
#ifndef SOL_IN_DEBUG_DETECTED #ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1 #define SOL_IN_DEBUG_DETECTED 1
#endif #endif
#endif // Not Debug && g++ optimizer flag #endif // Not Debug && g++ optimizer flag
#ifndef __EXCEPTIONS #ifndef __EXCEPTIONS
#ifndef SOL_NO_EXCEPTIONS #ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1 #define SOL_NO_EXCEPTIONS 1
#endif #endif
#endif // No Exceptions #endif // No Exceptions
#ifndef __GXX_RTTI #ifndef __GXX_RTTI
#ifndef SOL_NO_RTII #ifndef SOL_NO_RTII
#define SOL_NO_RTTI 1 #define SOL_NO_RTTI 1
#endif #endif
#endif // No RTTI #endif // No RTTI
#endif // vc++ || clang++/g++ #endif // vc++ || clang++/g++
#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS #if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS
// Checks low-level getter function // Checks low-level getter function
// (and thusly, affects nearly entire framework) // (and thusly, affects nearly entire framework)
#if !defined(SOL_SAFE_GETTER) #if !defined(SOL_SAFE_GETTER)
#define SOL_SAFE_GETTER 1 #define SOL_SAFE_GETTER 1
#endif #endif
// Checks access on usertype functions // Checks access on usertype functions
// local my_obj = my_type.new() // local my_obj = my_type.new()
// my_obj.my_member_function() // my_obj.my_member_function()
// -- bad syntax and crash // -- bad syntax and crash
#if !defined(SOL_SAFE_USERTYPE) #if !defined(SOL_SAFE_USERTYPE)
#define SOL_SAFE_USERTYPE 1 #define SOL_SAFE_USERTYPE 1
#endif #endif
// Checks sol::reference derived boundaries // Checks sol::reference derived boundaries
// sol::function ref(L, 1); // sol::function ref(L, 1);
// sol::userdata sref(L, 2); // sol::userdata sref(L, 2);
#if !defined(SOL_SAFE_REFERENCES) #if !defined(SOL_SAFE_REFERENCES)
#define SOL_SAFE_REFERENCES 1 #define SOL_SAFE_REFERENCES 1
#endif #endif
// Changes all typedefs of sol::function to point to the // Changes all typedefs of sol::function to point to the
// protected_function version, instead of unsafe_function // protected_function version, instead of unsafe_function
#if !defined(SOL_SAFE_FUNCTION) #if !defined(SOL_SAFE_FUNCTION)
#define SOL_SAFE_FUNCTION 1 #define SOL_SAFE_FUNCTION 1
#endif #endif
// Checks function parameters and // Checks function parameters and
// returns upon call into/from Lua // returns upon call into/from Lua
// local a = 1 // local a = 1
// local b = "woof" // local b = "woof"
// my_c_function(a, b) // my_c_function(a, b)
#if !defined(SOL_SAFE_FUNCTION_CALLS) #if !defined(SOL_SAFE_FUNCTION_CALLS)
#define SOL_SAFE_FUNCTION_CALLS 1 #define SOL_SAFE_FUNCTION_CALLS 1
#endif #endif
// Checks conversions // Checks conversions
// int v = lua["bark"]; // int v = lua["bark"];
// int v2 = my_sol_function(); // int v2 = my_sol_function();
#if !defined(SOL_SAFE_PROXIES) #if !defined(SOL_SAFE_PROXIES)
#define SOL_SAFE_PROXIES 1 #define SOL_SAFE_PROXIES 1
#endif #endif
// Check overflowing number conversions // Check overflowing number conversions
// for things like 64 bit integers that don't fit in a typical lua_Number // for things like 64 bit integers that don't fit in a typical lua_Number
// for Lua 5.1 and 5.2 // for Lua 5.1 and 5.2
#if !defined(SOL_SAFE_NUMERICS) #if !defined(SOL_SAFE_NUMERICS)
#define SOL_SAFE_NUMERICS 1 #define SOL_SAFE_NUMERICS 1
#endif #endif
// Turn off Number Precision Checks // Turn off Number Precision Checks
// if this is defined, we do not do range // if this is defined, we do not do range
// checks on integers / unsigned integers that might // checks on integers / unsigned integers that might
// be bigger than what Lua can represent // be bigger than what Lua can represent
#if !defined(SOL_NO_CHECK_NUMBER_PRECISION) #if !defined(SOL_NO_CHECK_NUMBER_PRECISION)
// off by default // off by default
#define SOL_NO_CHECK_NUMBER_PRECISION 0 #define SOL_NO_CHECK_NUMBER_PRECISION 0
#endif #endif
#endif // Turn on Safety for all if top-level macro is defined #endif // Turn on Safety for all if top-level macro is defined
#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED #if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED
#if !defined(SOL_SAFE_REFERENCES) #if !defined(SOL_SAFE_REFERENCES)
// Ensure that references are forcefully type-checked upon construction // Ensure that references are forcefully type-checked upon construction
#define SOL_SAFE_REFERENCES 1 #define SOL_SAFE_REFERENCES 1
#endif #endif
// Safe usertypes checks for errors such as // Safe usertypes checks for errors such as
// obj = my_type.new() // obj = my_type.new()
// obj.f() -- note the '.' instead of ':' // obj.f() -- note the '.' instead of ':'
// usertypes should be safe no matter what // usertypes should be safe no matter what
#if !defined(SOL_SAFE_USERTYPE) #if !defined(SOL_SAFE_USERTYPE)
#define SOL_SAFE_USERTYPE 1 #define SOL_SAFE_USERTYPE 1
#endif #endif
#if !defined(SOL_SAFE_FUNCTION_CALLS) #if !defined(SOL_SAFE_FUNCTION_CALLS)
// Function calls from Lua should be automatically safe in debug mode // Function calls from Lua should be automatically safe in debug mode
#define SOL_SAFE_FUNCTION_CALLS 1 #define SOL_SAFE_FUNCTION_CALLS 1
#endif #endif
// Print any exceptions / errors that occur // Print any exceptions / errors that occur
// in debug mode to the default error stream / console // in debug mode to the default error stream / console
#if !defined(SOL_PRINT_ERRORS) #if !defined(SOL_PRINT_ERRORS)
#define SOL_PRINT_ERRORS 1 #define SOL_PRINT_ERRORS 1
#endif #endif
#endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar #endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar
#if !defined(SOL_PRINT_ERRORS) #if !defined(SOL_PRINT_ERRORS)
#define SOL_PRINT_ERRORS 0 #define SOL_PRINT_ERRORS 0
#endif #endif
#if !defined(SOL_DEFAULT_PASS_ON_ERROR) #if !defined(SOL_DEFAULT_PASS_ON_ERROR)
#define SOL_DEFAULT_PASS_ON_ERROR 0 #define SOL_DEFAULT_PASS_ON_ERROR 0
#endif #endif
#if !defined(SOL_ENABLE_INTEROP) #if !defined(SOL_ENABLE_INTEROP)
#define SOL_ENABLE_INTEROP 0 #define SOL_ENABLE_INTEROP 0
#endif #endif
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) #if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
#if !defined(SOL_NO_NIL) #if !defined(SOL_NO_NIL)
#define SOL_NO_NIL 1 #define SOL_NO_NIL 1
#endif #endif
#endif // avoiding nil defines / keywords #endif // avoiding nil defines / keywords
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST #if defined(SOL_USE_BOOST) && SOL_USE_BOOST
#ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH #ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1 #define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1
#endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH #endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH
#endif #endif
#ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE #ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE
#define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024 #define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024
#endif // Optimized conversion routines using a KB or so off the stack #endif // Optimized conversion routines using a KB or so off the stack
// end of sol/config.hpp // end of sol/config.hpp
// end of sol/feature_test.hpp // beginning of sol/config_setup.hpp
namespace sol { // end of sol/config_setup.hpp
template <bool b> // end of sol/feature_test.hpp
class basic_reference;
using reference = basic_reference<false>; namespace sol {
using main_reference = basic_reference<true>;
class stack_reference; template <bool b>
class basic_reference;
struct proxy_base_tag; using reference = basic_reference<false>;
template <typename Super> using main_reference = basic_reference<true>;
struct proxy_base; class stack_reference;
template <typename Table, typename Key>
struct proxy; struct proxy_base_tag;
template <typename Super>
template <typename T> struct proxy_base;
class usertype; template <typename Table, typename Key>
template <typename T> struct proxy;
class simple_usertype;
template <bool, typename T> template <typename T>
class basic_table_core; class usertype;
template <bool b> template <typename T>
using table_core = basic_table_core<b, reference>; class simple_usertype;
template <bool b> template <bool, typename T>
using main_table_core = basic_table_core<b, main_reference>; class basic_table_core;
template <bool b> template <bool b>
using stack_table_core = basic_table_core<b, stack_reference>; using table_core = basic_table_core<b, reference>;
template <typename T> template <bool b>
using basic_table = basic_table_core<false, T>; using main_table_core = basic_table_core<b, main_reference>;
typedef table_core<false> table; template <bool b>
typedef table_core<true> global_table; using stack_table_core = basic_table_core<b, stack_reference>;
typedef main_table_core<false> main_table; template <typename T>
typedef main_table_core<true> main_global_table; using basic_table = basic_table_core<false, T>;
typedef stack_table_core<false> stack_table; typedef table_core<false> table;
typedef stack_table_core<true> stack_global_table; typedef table_core<true> global_table;
template <typename base_t> typedef main_table_core<false> main_table;
struct basic_environment; typedef main_table_core<true> main_global_table;
using environment = basic_environment<reference>; typedef stack_table_core<false> stack_table;
using main_environment = basic_environment<main_reference>; typedef stack_table_core<true> stack_global_table;
using stack_environment = basic_environment<stack_reference>; template <typename base_t>
template <typename T, bool> struct basic_environment;
class basic_function; using environment = basic_environment<reference>;
template <typename T, bool, typename H> using main_environment = basic_environment<main_reference>;
class basic_protected_function; using stack_environment = basic_environment<stack_reference>;
using unsafe_function = basic_function<reference, false>; template <typename T, bool>
using safe_function = basic_protected_function<reference, false, reference>; class basic_function;
using main_unsafe_function = basic_function<main_reference, false>; template <typename T, bool, typename H>
using main_safe_function = basic_protected_function<main_reference, false, reference>; class basic_protected_function;
using stack_unsafe_function = basic_function<stack_reference, false>; using unsafe_function = basic_function<reference, false>;
using stack_safe_function = basic_protected_function<stack_reference, false, reference>; using safe_function = basic_protected_function<reference, false, reference>;
using stack_aligned_unsafe_function = basic_function<stack_reference, true>; using main_unsafe_function = basic_function<main_reference, false>;
using stack_aligned_safe_function = basic_protected_function<stack_reference, true, reference>; using main_safe_function = basic_protected_function<main_reference, false, reference>;
using protected_function = safe_function; using stack_unsafe_function = basic_function<stack_reference, false>;
using main_protected_function = main_safe_function; using stack_safe_function = basic_protected_function<stack_reference, false, reference>;
using stack_protected_function = stack_safe_function; using stack_aligned_unsafe_function = basic_function<stack_reference, true>;
using stack_aligned_protected_function = stack_aligned_safe_function; using stack_aligned_safe_function = basic_protected_function<stack_reference, true, reference>;
#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION using protected_function = safe_function;
using function = protected_function; using main_protected_function = main_safe_function;
using main_function = main_protected_function; using stack_protected_function = stack_safe_function;
using stack_function = stack_protected_function; using stack_aligned_protected_function = stack_aligned_safe_function;
#else #if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
using function = unsafe_function; using function = protected_function;
using main_function = main_unsafe_function; using main_function = main_protected_function;
using stack_function = stack_unsafe_function; using stack_function = stack_protected_function;
#endif #else
using stack_aligned_function = stack_aligned_unsafe_function; using function = unsafe_function;
using stack_aligned_stack_handler_function = basic_protected_function<stack_reference, true, stack_reference>; using main_function = main_unsafe_function;
using stack_function = stack_unsafe_function;
struct unsafe_function_result; #endif
struct protected_function_result; using stack_aligned_function = stack_aligned_unsafe_function;
using safe_function_result = protected_function_result; using stack_aligned_stack_handler_function = basic_protected_function<stack_reference, true, stack_reference>;
#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
using function_result = safe_function_result; struct unsafe_function_result;
#else struct protected_function_result;
using function_result = unsafe_function_result; using safe_function_result = protected_function_result;
#endif #if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
using function_result = safe_function_result;
template <typename base_t> #else
class basic_object; using function_result = unsafe_function_result;
template <typename base_t> #endif
class basic_userdata;
template <typename base_t> template <typename base_t>
class basic_lightuserdata; class basic_object;
template <typename base_t> template <typename base_t>
class basic_coroutine; class basic_userdata;
template <typename base_t> template <typename base_t>
class basic_thread; class basic_lightuserdata;
template <typename base_t>
using object = basic_object<reference>; class basic_coroutine;
using userdata = basic_userdata<reference>; template <typename base_t>
using lightuserdata = basic_lightuserdata<reference>; class basic_thread;
using thread = basic_thread<reference>;
using coroutine = basic_coroutine<reference>; using object = basic_object<reference>;
using main_object = basic_object<main_reference>; using userdata = basic_userdata<reference>;
using main_userdata = basic_userdata<main_reference>; using lightuserdata = basic_lightuserdata<reference>;
using main_lightuserdata = basic_lightuserdata<main_reference>; using thread = basic_thread<reference>;
using main_coroutine = basic_coroutine<main_reference>; using coroutine = basic_coroutine<reference>;
using stack_object = basic_object<stack_reference>; using main_object = basic_object<main_reference>;
using stack_userdata = basic_userdata<stack_reference>; using main_userdata = basic_userdata<main_reference>;
using stack_lightuserdata = basic_lightuserdata<stack_reference>; using main_lightuserdata = basic_lightuserdata<main_reference>;
using stack_thread = basic_thread<stack_reference>; using main_coroutine = basic_coroutine<main_reference>;
using stack_coroutine = basic_coroutine<stack_reference>; using stack_object = basic_object<stack_reference>;
using stack_userdata = basic_userdata<stack_reference>;
struct stack_proxy_base; using stack_lightuserdata = basic_lightuserdata<stack_reference>;
struct stack_proxy; using stack_thread = basic_thread<stack_reference>;
struct variadic_args; using stack_coroutine = basic_coroutine<stack_reference>;
struct variadic_results;
struct stack_count; struct stack_proxy_base;
struct this_state; struct stack_proxy;
struct this_main_state; struct variadic_args;
struct this_environment; struct variadic_results;
struct stack_count;
template <typename T> struct this_state;
struct as_table_t; struct this_main_state;
template <typename T> struct this_environment;
struct as_container_t;
template <typename T> template <typename T>
struct nested; struct as_table_t;
template <typename T> template <typename T>
struct light; struct as_container_t;
template <typename T> template <typename T>
struct user; struct nested;
template <typename T> template <typename T>
struct as_args_t; struct light;
template <typename T> template <typename T>
struct protect_t; struct user;
template <typename F, typename... Filters> template <typename T>
struct filter_wrapper; struct as_args_t;
} // namespace sol template <typename T>
struct protect_t;
// end of sol/forward.hpp template <typename F, typename... Filters>
struct filter_wrapper;
#endif // SOL_SINGLE_INCLUDE_FORWARD_HPP } // namespace sol
// end of sol/forward.hpp
#endif // SOL_SINGLE_INCLUDE_FORWARD_HPP

View File

@ -252,27 +252,44 @@ namespace stack {
struct pusher<detail::as_table_tag<T>> { struct pusher<detail::as_table_tag<T>> {
static int push(lua_State* L, const T& tablecont) { static int push(lua_State* L, const T& tablecont) {
typedef meta::has_key_value_pair<meta::unqualified_t<std::remove_pointer_t<T>>> has_kvp; typedef meta::has_key_value_pair<meta::unqualified_t<std::remove_pointer_t<T>>> has_kvp;
return push(has_kvp(), L, tablecont); return push(has_kvp(), std::false_type(), L, tablecont);
} }
static int push(std::true_type, lua_State* L, const T& tablecont) { static int push(std::true_type, lua_State* L, const T& tablecont) {
typedef meta::has_key_value_pair<meta::unqualified_t<std::remove_pointer_t<T>>> has_kvp;
return push(has_kvp(), std::true_type(), L, tablecont);
}
static int push(std::false_type, lua_State* L, const T& tablecont) {
typedef meta::has_key_value_pair<meta::unqualified_t<std::remove_pointer_t<T>>> has_kvp;
return push(has_kvp(), std::false_type(), L, tablecont);
}
template <bool is_nested>
static int push(std::true_type, std::integral_constant<bool, is_nested>, lua_State* L, const T& tablecont) {
auto& cont = detail::deref(detail::unwrap(tablecont)); auto& cont = detail::deref(detail::unwrap(tablecont));
lua_createtable(L, static_cast<int>(cont.size()), 0); lua_createtable(L, static_cast<int>(cont.size()), 0);
int tableindex = lua_gettop(L); int tableindex = lua_gettop(L);
for (const auto& pair : cont) { for (const auto& pair : cont) {
set_field(L, pair.first, pair.second, tableindex); if (is_nested) {
set_field(L, pair.first, as_nested_ref(pair.second), tableindex);
}
else {
set_field(L, pair.first, pair.second, tableindex);
}
} }
return 1; return 1;
} }
static int push(std::false_type, lua_State* L, const T& tablecont) { template <bool is_nested>
static int push(std::false_type, std::integral_constant<bool, is_nested>, lua_State* L, const T& tablecont) {
auto& cont = detail::deref(detail::unwrap(tablecont)); auto& cont = detail::deref(detail::unwrap(tablecont));
lua_createtable(L, stack_detail::get_size_hint(cont), 0); lua_createtable(L, stack_detail::get_size_hint(cont), 0);
int tableindex = lua_gettop(L); int tableindex = lua_gettop(L);
std::size_t index = 1; std::size_t index = 1;
for (const auto& i : cont) { for (const auto& i : cont) {
#if SOL_LUA_VERSION >= 503 #if SOL_LUA_VERSION >= 503
int p = stack::push(L, i); int p = is_nested ? stack::push(L, as_nested_ref(i)) : stack::push(L, i);
for (int pi = 0; pi < p; ++pi) { for (int pi = 0; pi < p; ++pi) {
lua_seti(L, tableindex, static_cast<lua_Integer>(index++)); lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
} }
@ -317,9 +334,19 @@ namespace stack {
}; };
template <typename T> template <typename T>
struct pusher<nested<T>> { struct pusher<nested<T>, std::enable_if_t<is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
static int push(lua_State* L, const T& tablecont) { static int push(lua_State* L, const T& tablecont) {
pusher<as_table_t<T>> p{}; pusher<detail::as_table_tag<T>> p{};
// silence annoying VC++ warning
(void)p;
return p.push(std::true_type(), L, tablecont);
}
};
template <typename T>
struct pusher<nested<T>, std::enable_if_t<!is_container<std::remove_pointer_t<meta::unwrap_unqualified_t<T>>>::value>> {
static int push(lua_State* L, const T& tablecont) {
pusher<meta::unqualified_t<T>> p{};
// silence annoying VC++ warning // silence annoying VC++ warning
(void)p; (void)p;
return p.push(L, tablecont); return p.push(L, tablecont);

View File

@ -346,6 +346,44 @@ TEST_CASE("containers/from table argument conversions", "test table conversions
REQUIRE(passed); REQUIRE(passed);
} }
TEST_CASE("containers/deeply nested", "make sure nested works for deeply-nested C++ containers and works as advertised") {
typedef std::map<const char *, std::string> info_t;
typedef std::vector<info_t> info_vector;
class ModList {
public:
info_vector list;
ModList() {
list.push_back(info_t{
{"a", "b"}
});
}
sol::nested<info_vector> getList () {
return sol::nested<info_vector>(list);
};
};
sol::state lua;
lua.open_libraries(sol::lib::base);
lua.new_usertype<ModList>("ModList",
"getList", &ModList::getList
);
sol::string_view code = R"(
mods = ModList.new()
local modlist = mods:getList()
print(modlist[1])
assert(type(modlist) == "table")
assert(type(modlist[1]) == "table")
)";
auto result1 = lua.safe_script(code, sol::script_pass_on_error);
REQUIRE(result1.valid());
}
TEST_CASE("containers/vector roundtrip", "make sure vectors can be round-tripped") { TEST_CASE("containers/vector roundtrip", "make sure vectors can be round-tripped") {
sol::state lua; sol::state lua;
std::vector<int> v{ 1, 2, 3 }; std::vector<int> v{ 1, 2, 3 };