From 017b2cfac18246db17266672853c4ed616ddab92 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 21 May 2019 21:28:18 -0400 Subject: [PATCH] update single and improve safety config documentation --- docs/source/safety.rst | 12 ++++++++---- examples/source/table_create_if_nil.cpp | 1 + single/include/sol/forward.hpp | 10 ++++++++-- single/include/sol/sol.hpp | 14 ++++++++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/docs/source/safety.rst b/docs/source/safety.rst index 47645070..73ccff22 100644 --- a/docs/source/safety.rst +++ b/docs/source/safety.rst @@ -47,6 +47,10 @@ Safety Config * Affects nearly the entire library for safety (with some blind spots covered by the other definitions) * **Not** turned on by default under any settings: *this MUST be turned on manually* +``SOL_ALL_SAFETIES_ON`` triggers the following changes: + * If ``SOL_SAFE_USERTYPE``, ``SOL_SAFE_REFERENCES``, ``SOL_SAFE_FUNCTION``, ``SOL_SAFE_NUMERICS``, ``SOL_SAFE_GETTER``, and ``SOL_SAFE_FUNCTION_CALLS`` are not defined, they get defined and the effects described above kick in + * **Not** turned on by default under any settings: *this MUST be turned on manually* + ``SOL_DEFAULT_PASS_ON_ERROR`` triggers the following changes: * The default error handler for ``sol::state_view::script_`` functions is ``sol::script_pass_on_error`` rather than ``sol::script_throw_on_error`` * Passes errors on through: **very dangerous** as you can ignore or never be warned about errors if you don't catch the return value of specific functions @@ -54,10 +58,6 @@ Safety Config * Don't turn this on unless you have an extremely good reason * *DON'T TURN THIS ON UNLESS YOU HAVE AN EXTREMELY GOOD REASON* -``SOL_ALL_SAFETIES_ON`` triggers the following changes: - * If ``SOL_SAFE_USERTYPE``, ``SOL_SAFE_REFERENCES``, ``SOL_SAFE_FUNCTION``, ``SOL_SAFE_NUMERICS``, ``SOL_SAFE_GETTER``, and ``SOL_SAFE_FUNCTION_CALLS`` are not defined, they get defined and the effects described above kick in - * **Not** turned on by default under any settings: *this MUST be turned on manually* - ``SOL_NO_CHECK_NUMBER_PRECISION`` triggers the following changes: * If ``SOL_SAFE_NUMERICS`` is defined, turns off number precision and integer precision fitting when pushing numbers into sol2 * **Not** turned on by default under any settings: *this MUST be turned on manually* @@ -72,6 +72,10 @@ Safety Config * Overrides safety and always applies if it is turned on * **Not** turned on by default under any settings: *this MUST be turned on manually* +``SOL_CHECK_ARGUMENTS`` is a deprecated define that will be removed soon: + * It is simply an alias for ``SOL_ALL_SAFETIES_ON`` + * Please change all your code to use ``SOL_ALL_SAFETIES_ON`` + .. _config-feature: Feature Config diff --git a/examples/source/table_create_if_nil.cpp b/examples/source/table_create_if_nil.cpp index 04ddcd73..0ccc47ca 100644 --- a/examples/source/table_create_if_nil.cpp +++ b/examples/source/table_create_if_nil.cpp @@ -2,6 +2,7 @@ #include #include "assert.hpp" +#include void create_namespace_sf(sol::state& lua) { // this would explode diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index 6c6c2a3c..da781bfb 100644 --- a/single/include/sol/forward.hpp +++ b/single/include/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 2019-05-21 07:55:59.916335 UTC -// This header was generated with sol v3.0.1-beta2 (revision ad1b966) +// Generated 2019-05-21 23:28:10.944171 UTC +// This header was generated with sol v3.0.2 (revision f701fd2) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP @@ -99,6 +99,12 @@ #endif // vc++ || clang++/g++ +#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS + #if defined(SOL_ALL_SAFETIES_ON) + #define SOL_ALL_SAFETIES_ON 1 + #endif // turn all the safeties on +#endif // Compatibility define + #if defined(SOL_ALL_SAFETIES_ON) && SOL_ALL_SAFETIES_ON // Checks low-level getter function diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index 6059ea6c..78605807 100644 --- a/single/include/sol/sol.hpp +++ b/single/include/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 2019-05-21 07:55:59.198915 UTC -// This header was generated with sol v3.0.1-beta2 (revision ad1b966) +// Generated 2019-05-21 23:28:10.673891 UTC +// This header was generated with sol v3.0.2 (revision f701fd2) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -126,6 +126,12 @@ #endif // vc++ || clang++/g++ #if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS + #if defined(SOL_ALL_SAFETIES_ON) + #define SOL_ALL_SAFETIES_ON 1 + #endif // turn all the safeties on +#endif // Compatibility define + +#if defined(SOL_ALL_SAFETIES_ON) && SOL_ALL_SAFETIES_ON // Checks low-level getter function // (and thusly, affects nearly entire framework) @@ -4726,7 +4732,7 @@ namespace sol { /// \exclude constexpr optional(const T& u) : base(in_place, u) { } -#endif // sol2 modification +#endif // sol3 modification /// Converting copy constructor. /// \synopsis template optional(const optional &rhs); @@ -11818,7 +11824,7 @@ namespace sol { namespace stack { // Because additional lambdas / functions which serve as // capture-all-and-then-invoke bloat binary sizes // by an actually detectable amount - // (one user uses sol3 pretty heavily and 22 MB of binary size + // (one user uses sol2 pretty heavily and 22 MB of binary size // was saved by reducing reliance on lambdas in templates) // This would really be solved by having break N;