MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaL_testudata

Function luaL_testudata

freebsd/contrib/openzfs/module/lua/lauxlib.c:250–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248
249
250LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
251 void *p = lua_touserdata(L, ud);
252 if (p != NULL) { /* value is a userdata? */
253 if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
254 luaL_getmetatable(L, tname); /* get correct metatable */
255 if (!lua_rawequal(L, -1, -2)) /* not the same? */
256 p = NULL; /* value is a userdata with wrong metatable */
257 lua_pop(L, 2); /* remove both metatables */
258 return p;
259 }
260 }
261 return NULL; /* value is not a userdata with a metatable */
262}
263
264
265LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {

Callers 1

luaL_checkudataFunction · 0.85

Calls 3

lua_touserdataFunction · 0.70
lua_getmetatableFunction · 0.70
lua_rawequalFunction · 0.70

Tested by

no test coverage detected