Uses some of the fancier bits of sol2, including the "transparent argument", sol::this_state, which gets the current state and does not increment function arguments
| 7 | // "transparent argument", sol::this_state, which gets the |
| 8 | // current state and does not increment function arguments |
| 9 | sol::object fancy_func( |
| 10 | sol::object a, sol::object b, sol::this_state s) { |
| 11 | sol::state_view lua(s); |
| 12 | if (a.is<int>() && b.is<int>()) { |
| 13 | return sol::object( |
| 14 | lua, sol::in_place, a.as<int>() + b.as<int>()); |
| 15 | } |
| 16 | else if (a.is<bool>()) { |
| 17 | bool do_triple = a.as<bool>(); |
| 18 | return sol::object(lua, |
| 19 | sol::in_place_type<double>, |
| 20 | b.as<double>() * (do_triple ? 3 : 1)); |
| 21 | } |
| 22 | // Can also use make_object |
| 23 | return sol::make_object(lua, sol::lua_nil); |
| 24 | } |
| 25 | |
| 26 | int main() { |
| 27 | sol::state lua; |
nothing calls this directly
no test coverage detected