| 328 | |
| 329 | |
| 330 | LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { |
| 331 | void *p = lua_touserdata(L, ud); |
| 332 | if (p != NULL) { /* value is a userdata? */ |
| 333 | if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ |
| 334 | luaL_getmetatable(L, tname); /* get correct metatable */ |
| 335 | if (!lua_rawequal(L, -1, -2)) /* not the same? */ |
| 336 | p = NULL; /* value is a userdata with wrong metatable */ |
| 337 | lua_pop(L, 2); /* remove both metatables */ |
| 338 | return p; |
| 339 | } |
| 340 | } |
| 341 | return NULL; /* value is not a userdata with a metatable */ |
| 342 | } |
| 343 | |
| 344 | |
| 345 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { |
no test coverage detected