| 162 | |
| 163 | |
| 164 | bool 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 | |
| 191 | std::string LuaHandle::LoadSourceCode(const std::string& sourceFile, |
nothing calls this directly
no test coverage detected