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

Method PushLib

src/lua/LuaHandle.cpp:164–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162
163
164bool LuaHandle::PushLib(const char* name, bool (*entriesFunc)(lua_State*)) {
165 const int top = lua_gettop(L);
166 lua_pushstring(L, name);
167 lua_rawget(L, -2);
168 if (lua_istable(L, -1)) {
169 const bool success = entriesFunc(L);
170 lua_pop(L, 1);
171 CheckEqualStack(this, L, top, name);
172 return success;
173 }
174 lua_pop(L, 1);
175
176 // make a new table
177 lua_pushstring(L, name);
178 lua_newtable(L);
179 const bool success = entriesFunc(L);
180 if (!success) {
181 lua_pop(L, 2);
182 CheckEqualStack(this, L, top, name);
183 return false;
184 }
185 lua_rawset(L, -3);
186 CheckEqualStack(this, L, top, name);
187 return true;
188}
189
190
191std::string LuaHandle::LoadSourceCode(const std::string& sourceFile,

Callers

nothing calls this directly

Calls 5

CheckEqualStackFunction · 0.85
lua_gettopFunction · 0.50
lua_pushstringFunction · 0.50
lua_rawgetFunction · 0.50
lua_rawsetFunction · 0.50

Tested by

no test coverage detected