sol2
sol2 copied to clipboard
Environments and lua_Reader cannot be used together
The problem:
Currently (in sol2 version 3.3.0) there is no way to use sol::environment
and lua_Reader
together. sol::state::safe_script
doesn't have an overload that can accept both, and sol::set_environment
doesn't accept sol::load_result
.
Why I have this problem:
I'm using Sol in an environment that I can't make any assumptions about the provided scripts. I'm planning to utilize sol::environment
to prevent scripts from calling potentially dangerous functions that are provided by the Lua libraries. I can't be sure that the loaded scripts are small enough to fit in the ram, so loading all of the script to a std::string
is not a viable option, and I might need to load scripts from non-conventional sources in the future, so loading the script using sol::state::safe_script_file
is not a viable option either. So my only option is to use lua_Reader
.
Possible solutions
- Adding an overload to
sol::state::(safe_)script
that acceptslua_Reader
andsol::environment
at the same time. - Allowing
sol::environment::set_on
andsol::set_environment
to acceptsol::load_result
.