| 122 | |
| 123 | |
| 124 | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { |
| 125 | void *p = lua_touserdata(L, ud); |
| 126 | if (p != NULL) { /* value is a userdata? */ |
| 127 | if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ |
| 128 | lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ |
| 129 | if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ |
| 130 | lua_pop(L, 2); /* remove both metatables */ |
| 131 | return p; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | luaL_typerror(L, ud, tname); /* else error */ |
| 136 | return NULL; /* to avoid warnings */ |
| 137 | } |
| 138 | |
| 139 | |
| 140 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { |
no test coverage detected