MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / AddCallInError

Function AddCallInError

src/lua/LuaHandle.cpp:273–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271//============================================================================//
272
273static 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
307bool LuaHandle::RunCallIn(int ciCode, int inArgs, int outArgs) {

Callers 1

RunCallInMethod · 0.85

Calls 8

lua_pushstdstringFunction · 0.85
lua_checkstackFunction · 0.50
lua_rawgetFunction · 0.50
lua_createtableFunction · 0.50
lua_pushvalueFunction · 0.50
lua_rawsetFunction · 0.50
lua_objlenFunction · 0.50
lua_rawsetiFunction · 0.50

Tested by

no test coverage detected