| 271 | //============================================================================// |
| 272 | |
| 273 | static void AddCallInError(lua_State* L, const std::string& funcName) { |
| 274 | // error string is on the top of the stack |
| 275 | lua_checkstack(L, 4); |
| 276 | |
| 277 | lua_pushliteral(L, "ERRORS"); |
| 278 | lua_rawget(L, LUA_GLOBALSINDEX); |
| 279 | if (!lua_istable(L, -1)) { |
| 280 | lua_pop(L, 1); |
| 281 | lua_createtable(L, 0, 0); |
| 282 | lua_pushliteral(L, "ERRORS"); |
| 283 | lua_pushvalue(L, -2); // make a copy of {ERRORS} |
| 284 | lua_rawset(L, LUA_GLOBALSINDEX); |
| 285 | } |
| 286 | |
| 287 | const size_t len = lua_objlen(L, -1); |
| 288 | if (len >= 1024) { |
| 289 | lua_pop(L, 2); |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | lua_createtable(L, 0, 2); { |
| 294 | lua_pushliteral(L, "func"); |
| 295 | lua_pushstdstring(L, funcName); |
| 296 | lua_rawset(L, -3); |
| 297 | lua_pushliteral(L, "error"); |
| 298 | lua_pushvalue(L, -4); |
| 299 | lua_rawset(L, -3); |
| 300 | } |
| 301 | lua_rawseti(L, -2, len + 1); |
| 302 | |
| 303 | lua_pop(L, 2); // also pop the message |
| 304 | } |
| 305 | |
| 306 | |
| 307 | bool LuaHandle::RunCallIn(int ciCode, int inArgs, int outArgs) { |
no test coverage detected