mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
[ci skip] safety docs
This commit is contained in:
parent
54608201fc
commit
4aec055004
|
@ -3,7 +3,7 @@ safety
|
||||||
|
|
||||||
Sol was designed to be correct and fast, and in the pursuit of both uses the regular ``lua_to{x}`` functions of Lua rather than the checking versions (``lua_check{X}``) functions. The API defaults to paranoidly-safe alternatives if you have a ``#define SOL_CHECK_ARGUMENTS`` before you include Sol, or if you pass the ``SOL_CHECK_ARGUMENTS`` define on the build command for your build system. By default, it is off and remains off unless you define this, even in debug mode. The same goes for ``#define SOL_SAFE_USERTYPE``.
|
Sol was designed to be correct and fast, and in the pursuit of both uses the regular ``lua_to{x}`` functions of Lua rather than the checking versions (``lua_check{X}``) functions. The API defaults to paranoidly-safe alternatives if you have a ``#define SOL_CHECK_ARGUMENTS`` before you include Sol, or if you pass the ``SOL_CHECK_ARGUMENTS`` define on the build command for your build system. By default, it is off and remains off unless you define this, even in debug mode. The same goes for ``#define SOL_SAFE_USERTYPE``.
|
||||||
|
|
||||||
Note that you can obtain safety with regards to functions you bind by using the :doc:`protect<api/protect>` wrapper around function/variable bindings you set into Lua.
|
Note that you can obtain safety with regards to functions you bind by using the :doc:`protect<api/protect>` wrapper around function/variable bindings you set into Lua. Additionally, you can have basic boolean checks when using the API by just converting to a :doc:`sol::optional\<T><api/optional>` when necessary for getting things out of Lua and for function arguments.
|
||||||
|
|
||||||
``SOL_SAFE_USERTYPE`` triggers the following change:
|
``SOL_SAFE_USERTYPE`` triggers the following change:
|
||||||
* If the userdata to a usertype function is nil, will trigger an error instead of letting things go through and letting the system segfault.
|
* If the userdata to a usertype function is nil, will trigger an error instead of letting things go through and letting the system segfault.
|
||||||
|
@ -13,7 +13,7 @@ Note that you can obtain safety with regards to functions you bind by using the
|
||||||
* ``sol::stack::call`` and its variants will, if no templated boolean is specified, check all of the arguments for a function call.
|
* ``sol::stack::call`` and its variants will, if no templated boolean is specified, check all of the arguments for a function call.
|
||||||
* If ``SOL_SAFE_USERTYPE`` is not defined, it gets defined to turn being on.
|
* If ``SOL_SAFE_USERTYPE`` is not defined, it gets defined to turn being on.
|
||||||
|
|
||||||
Remember that if you want these features, you must explicitly turn them on. Additionally, you can have basic boolean checks when using the API by just converting to a :doc:`sol::optional\<T><api/optional>` when necessary. Tests are compiled with this on to ensure everythign is going as expected.
|
Tests are compiled with this on to ensure everything is going as expected. Remember that if you want these features, you must explicitly turn them on.
|
||||||
|
|
||||||
Finally, some warnings that may help with errors when working with Sol:
|
Finally, some warnings that may help with errors when working with Sol:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user