From ac709111e81167f81b23fda9c7d9c6d3a70c2874 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 22 May 2018 15:42:38 -0400 Subject: [PATCH] ensure index_adjustment is applied everywhere add safety config everywhere --- docs/source/safety.rst | 5 +++++ single/sol/sol.hpp | 8 ++++++-- single/sol/sol_forward.hpp | 4 ++-- sol/container_traits.hpp | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/source/safety.rst b/docs/source/safety.rst index 12affb289..79e51e677 100644 --- a/docs/source/safety.rst +++ b/docs/source/safety.rst @@ -84,6 +84,11 @@ Feature Config * Includes ```` and prints all exceptions and errors to ``std::cerr``, for you to see * **Not** turned on by default under any settings: *this MUST be turned on manually* +``SOL_CONTAINERS_START`` triggers the following change: + * If defined and **is an integral value**, is used to adjust the container start value + * Applies to C++ containers **only** (not Lua tables or algorithms) + * Defaults to 1 (containers in Lua count from 1) + ``SOL_ENABLE_INTEROP`` triggers the following change: * Allows the use of ``extensible`` to be used with ``userdata_checker`` and ``userdata_getter`` to retrieve non-sol usertypes - Particularly enables non-sol usertypes to be used in overloads diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 7a28d3537..5abaa9c4e 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -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-05-20 19:25:19.981188 UTC -// This header was generated with sol v2.20.1 (revision 4f366a1) +// Generated 2018-05-22 19:42:19.603781 UTC +// This header was generated with sol v2.20.2 (revision d67c5b7) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -16949,7 +16949,11 @@ namespace sol { } static std::ptrdiff_t index_adjustment(lua_State*, T&) { +#if defined(SOL_CONTAINERS_START_INDEX) + return static_cast((SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START)); +#else return static_cast(-1); +#endif } static int pairs(lua_State* L) { diff --git a/single/sol/sol_forward.hpp b/single/sol/sol_forward.hpp index 8cf2b83f9..bc55b02cb 100644 --- a/single/sol/sol_forward.hpp +++ b/single/sol/sol_forward.hpp @@ -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-05-20 19:25:20.251908 UTC -// This header was generated with sol v2.20.1 (revision 4f366a1) +// Generated 2018-05-22 19:42:19.843589 UTC +// This header was generated with sol v2.20.2 (revision d67c5b7) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP diff --git a/sol/container_traits.hpp b/sol/container_traits.hpp index 1d3fc4d32..ee0acf48e 100644 --- a/sol/container_traits.hpp +++ b/sol/container_traits.hpp @@ -1273,7 +1273,11 @@ namespace sol { } static std::ptrdiff_t index_adjustment(lua_State*, T&) { +#if defined(SOL_CONTAINERS_START_INDEX) + return static_cast((SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START)); +#else return static_cast(-1); +#endif } static int pairs(lua_State* L) {