| 2 | #include <sol/sol.hpp> |
| 3 | |
| 4 | int main() { |
| 5 | struct callable { |
| 6 | int operator()(int a, bool b) { |
| 7 | return a + (b ? 10 : 20); |
| 8 | } |
| 9 | }; |
| 10 | |
| 11 | |
| 12 | sol::state lua; |
| 13 | // Binds struct as userdata |
| 14 | // can still be callable, but beware |
| 15 | // caveats |
| 16 | lua.set("not_func", callable()); |
| 17 | // Binds struct as function |
| 18 | lua.set("func", sol::as_function(callable())); |
| 19 | // equivalent: lua.set_function( "func", callable() ); |
| 20 | // equivalent: lua["func"] = callable(); |
| 21 | } |
nothing calls this directly
no test coverage detected