MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaL_testudata

Function luaL_testudata

lib/lua/src/lauxlib.c:333–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

luaL_checkudataFunction · 0.85
io_typeFunction · 0.85

Calls 3

lua_touserdataFunction · 0.85
lua_getmetatableFunction · 0.85
lua_rawequalFunction · 0.85

Tested by

no test coverage detected