2019-05-21 19:17:31 -04:00
|
|
|
#define SOL_ALL_SAFETIES_ON 1
|
2018-09-27 22:27:38 -07:00
|
|
|
#include <sol/sol.hpp>
|
2018-03-15 17:16:28 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <set>
|
|
|
|
|
|
2021-03-06 01:03:23 -05:00
|
|
|
int main() {
|
2018-03-15 17:16:28 -04:00
|
|
|
sol::state lua;
|
|
|
|
|
|
|
|
|
|
lua.set_function("f", []() {
|
2021-03-06 10:14:48 -05:00
|
|
|
std::set<std::string> results {
|
|
|
|
|
"arf", "bark", "woof"
|
|
|
|
|
};
|
2018-03-15 17:16:28 -04:00
|
|
|
return sol::as_returns(std::move(results));
|
|
|
|
|
});
|
2021-03-06 01:03:23 -05:00
|
|
|
|
2018-03-15 17:16:28 -04:00
|
|
|
lua.script("v1, v2, v3 = f()");
|
|
|
|
|
|
|
|
|
|
std::string v1 = lua["v1"];
|
|
|
|
|
std::string v2 = lua["v2"];
|
|
|
|
|
std::string v3 = lua["v3"];
|
|
|
|
|
|
2022-09-28 01:56:26 -04:00
|
|
|
SOL_ASSERT(v1 == "arf");
|
|
|
|
|
SOL_ASSERT(v2 == "bark");
|
|
|
|
|
SOL_ASSERT(v3 == "woof");
|
2018-03-15 17:16:28 -04:00
|
|
|
|
2021-03-06 01:03:23 -05:00
|
|
|
return 0;
|
2018-03-15 17:16:28 -04:00
|
|
|
}
|