| 261 | } |
| 262 | |
| 263 | bool CallMetaFunction(lua_State *L, int valueIndex, const char *method, int numResults, int &result) { |
| 264 | if (lua_getmetatable(L, valueIndex)) { |
| 265 | const int metaIndex = lua_gettop(L); |
| 266 | if (!lua_isnil(L, metaIndex)) { |
| 267 | lua_pushstring(L, method); |
| 268 | lua_rawget(L, metaIndex); |
| 269 | if (lua_isnil(L, -1)) { |
| 270 | // The meta-method doesn't exist. |
| 271 | lua_pop(L, 1); |
| 272 | lua_remove(L, metaIndex); |
| 273 | return false; |
| 274 | } |
| 275 | lua_pushvalue(L, valueIndex); |
| 276 | result = lua_pcall(L, 1, numResults, 0); |
| 277 | } |
| 278 | lua_remove(L, metaIndex); |
| 279 | return true; |
| 280 | } |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | std::string ToPointer(lua_State *L, int index) { |
| 285 | const void *pointer = lua_topointer(L, index); |
no test coverage detected