| 210 | } |
| 211 | |
| 212 | scripting::common_func lua::create_lambda(State* L) { |
| 213 | auto funcptr = create_lambda_handler(L); |
| 214 | return [=](const std::vector<dynamic::Value>& args) { |
| 215 | getglobal(L, LAMBDAS_TABLE); |
| 216 | getfield(L, *funcptr); |
| 217 | for (const auto& arg : args) { |
| 218 | pushvalue(L, arg); |
| 219 | } |
| 220 | if (call(L, args.size(), 1)) { |
| 221 | auto result = tovalue(L, -1); |
| 222 | pop(L); |
| 223 | return result; |
| 224 | } |
| 225 | return dynamic::Value(dynamic::NONE); |
| 226 | }; |
| 227 | } |
| 228 | |
| 229 | int lua::create_environment(State* L, int parent) { |
| 230 | int id = nextEnvironment++; |