diff --git a/docs/source/safety.rst b/docs/source/safety.rst index 73ccff22..20adb355 100644 --- a/docs/source/safety.rst +++ b/docs/source/safety.rst @@ -101,6 +101,12 @@ Feature Config * May come with a slight performance penalty: only recommended for those stuck with non-sol libraries that still need to leverage some of sol's power * **Not** turned on by default under any settings: *this MUST be turned on manually* +``SOL_AUTOMAGICAL_TYPES_BY_DEFAULT`` triggers the following change: + * Either turns on (``!= 0``) or turns off (``== 0``) automagical usertype detection by default. + * Automagical usertypes search for specific C++ conventions to define common methods for the end-user. + * Some automagical methods might cause huge compiler errors, and some people have code bases with different conventions. + * Turned on by default. This *must be turned off manually*. + .. _config-memory: Memory Config diff --git a/include/sol/config.hpp b/include/sol/config.hpp index 2ba18ef5..3fca8b29 100644 --- a/include/sol/config.hpp +++ b/include/sol/config.hpp @@ -234,4 +234,12 @@ #define SOL_SAFE_STACK_CHECK 0 #endif // use luaL_checkstack to check stack overflow / overrun +// This macro gives automagic type checks by default. +// Some types don't quite conform to this, so a few people +// want it to be turned off globally, all the time. +// the trait can still be specialized to help with that. +#if !defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) +#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT 1 +#endif // make is_automagical on/off by default + #endif // SOL_CONFIG_HPP diff --git a/include/sol/types.hpp b/include/sol/types.hpp index 98cb7b13..fb42b6af 100644 --- a/include/sol/types.hpp +++ b/include/sol/types.hpp @@ -1289,8 +1289,10 @@ namespace sol { template struct is_automagical : std::integral_constant> || (!std::is_same_v, state> && !std::is_same_v, state_view>)> {}; + (SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0) + || (std::is_array_v< + meta::unqualified_t> || (!std::is_same_v, state> && !std::is_same_v, state_view>))> { + }; template inline type type_of() { diff --git a/single/include/sol/forward.hpp b/single/include/sol/forward.hpp index e172e86a..40579776 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 2020-05-07 02:16:42.603409 UTC -// This header was generated with sol v3.2.0 (revision 890cdd3) +// Generated 2020-05-17 22:16:45.211397 UTC +// This header was generated with sol v3.2.0 (revision 5022c4d) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP @@ -191,6 +191,10 @@ #define SOL_SAFE_STACK_CHECK 0 #endif // use luaL_checkstack to check stack overflow / overrun +#if !defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) +#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT 1 +#endif // make is_automagical on/off by default + // end of sol/config.hpp // beginning of sol/config_setup.hpp diff --git a/single/include/sol/sol.hpp b/single/include/sol/sol.hpp index c3e9bef0..07ce2f0b 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 2020-05-07 02:16:42.137643 UTC -// This header was generated with sol v3.2.0 (revision 890cdd3) +// Generated 2020-05-17 22:16:42.038395 UTC +// This header was generated with sol v3.2.0 (revision 5022c4d) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -217,6 +217,10 @@ #define SOL_SAFE_STACK_CHECK 0 #endif // use luaL_checkstack to check stack overflow / overrun +#if !defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) +#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT 1 +#endif // make is_automagical on/off by default + // end of sol/config.hpp // beginning of sol/config_setup.hpp @@ -7319,8 +7323,10 @@ namespace sol { template struct is_automagical : std::integral_constant> || (!std::is_same_v, state> && !std::is_same_v, state_view>)> {}; + (SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0) + || (std::is_array_v< + meta::unqualified_t> || (!std::is_same_v, state> && !std::is_same_v, state_view>))> { + }; template inline type type_of() {