Skip to content

Commit

Permalink
ensure index_adjustment is applied everywhere
Browse files Browse the repository at this point in the history
add safety config everywhere
  • Loading branch information
ThePhD committed May 22, 2018
1 parent d67c5b7 commit ac70911
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/source/safety.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Feature Config
* Includes ``<iostream>`` 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<T>`` to be used with ``userdata_checker`` and ``userdata_getter`` to retrieve non-sol usertypes
- Particularly enables non-sol usertypes to be used in overloads
Expand Down
8 changes: 6 additions & 2 deletions single/sol/sol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -16949,7 +16949,11 @@ namespace sol {
}

static std::ptrdiff_t index_adjustment(lua_State*, T&) {
#if defined(SOL_CONTAINERS_START_INDEX)
return static_cast<std::ptrdiff_t>((SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START));
#else
return static_cast<std::ptrdiff_t>(-1);
#endif
}

static int pairs(lua_State* L) {
Expand Down
4 changes: 2 additions & 2 deletions single/sol/sol_forward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions sol/container_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,11 @@ namespace sol {
}

static std::ptrdiff_t index_adjustment(lua_State*, T&) {
#if defined(SOL_CONTAINERS_START_INDEX)
return static_cast<std::ptrdiff_t>((SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START));
#else
return static_cast<std::ptrdiff_t>(-1);
#endif
}

static int pairs(lua_State* L) {
Expand Down

0 comments on commit ac70911

Please sign in to comment.